<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();
  
  xmlHttp.onreadystatechange = handleStateChange;
  xmlHttp.open("GET","innerHTMl.xml", true);
  xmlHttp.send(null);
   
}function handleStateChange() {
if(xmlHttp.readyState == 4) {
alert("hello");
if(xmlHttp.status == 200) {
alert("hello");
document.getElementById("results").innerHTML = xmlHttp.responseText;
}
}
}</script>
请问各位以上代码哪里出问题了 为什么xmlHttp.status =200的判断不通过

解决方案 »

  1.   

    xmlHttp.status==200 判断通不过 就证明xmlHttp.status是其他值啊(比如:404 、403)你可以用代码测试一下它的值:function handleStateChange(){   if(xmlHttp.readyState==4){
          
          if(xmlHttp.status==200){
               alert("success!");
          } else if(xmlHttp.status==403){
               alert("Access denied");
          } else if(xmlHttp.status==404){
               alert("Requested URL is not found");
          } else {
               alert("other error:"+xmlHttp.status);
          }
       }}
      

  2.   

    是404,找不到innerHTMl.xml文件,我把innerHTMl.xml放在和html文件同一目录了,为什么还是找不到?