ajax璇诲彇txt鏂囨湰鍐呭
鍙戝竷: 2008-11-20 17:10 | 浣滆: 缃戠粶杞浇 | 鏉ユ簮: 缃戠粶杞浇 | 鏌ョ湅: 27娆
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>5dwang.com</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(){
createXMLHttpRequest();
try{
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "data.txt", true);
xmlHttp.send(null);
}catch(exception){
alert("鎮ㄨ璁块棶鐨勮祫婧愪笉瀛樺湪!");
}
}
function handleStateChange(){
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200 || xmlHttp.status == 0){
// 鏄剧ず杩斿洖缁撴灉
document.getElementById("5dwang").innerHTML=xmlHttp.responseText;
}
}
}
</script>
</head>
<body>
<div id=5dwang></div>
<input type="button" value="return ajax responseText's value" onclick="startRequest();" />
</body>
</html>
娉細濡傛灉data.txt鏈変腑鏂囨椂锛屼細鍑虹幇涔辩爜锛
瑙e喅鏂规硶锛
data.txt鍙﹀瓨涓烘椂锛岀紪鐮佷篃閫夋嫨:utf-8
http_request_handler.http_request.setRequestHeader ("encoding", "utf-8");




发表于 2009-1-5 19:48
| 











