87,910
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc() {
xmlhttp = null;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest(); //Firefox,Opera,IE7,
}
else{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp != null) {
xmlhttp.onreadystatechange = state_Change();
xmlhttp.open("get", "/test1.txt", true);
xmlhttp.send();
}
else {
alert("浏览器不支持XMLHTTP!");
}
}
function state_Change(){
if (xmlhttp.readyState==4) {//4loaded
if (xmlhttp.status==200) {//OK
document.getElementById('T1').innerHTML=xmlhttp.responseText;
alert(xmlhttp.responsetxt);
}
else{
alert("Problem retrieving data:"+xmlhttp.statusText);
}
}
}
</script>
</head>
<body>
<div id="T1" style="border:1px solid black;height:40px;width:100px;padding:5">
</div>
<br />
<input type="button" value="Click" onclick="loadXMLDoc()" />
</body>
xmlhttp.onreadystatechange = state_Change();
改成
xmlhttp.onreadystatechange = state_Change;