日期:2014-05-17  浏览次数:20694 次

ajax请求没反应
window.onload = function () {
   xhr = new createXhr();
   LoadCountQY();
  }
function LoadCountQY() {
      xhr.open("get", "MainPageQY.ashx", true);
      xhr.setRequestHeader("If-Modified-Since","0");
      xhr.onreadystatechange = function () {
      if (xhr.readyState == 4 && xhr.status == 200) {
           var msg = xhr.responseText;
           alert(msg);
           if (msg != null || msg != "") {
                var json = eval(msg);
                LoadQY(json);
            }
       } else {
            alert("readyState:" + xhr.readyState + "----status:" + xhr.status);
       }
     }
       xhr.send(null);
   }

打印出来readyState:4---status:500
调试时发现一直进不了MainPageQY.ashx页面、路径也没有错、标点符号也看过了没问题,找来找去也没有的到原因、另外一段差不多的代码就没有问题、求大神帮我看下是哪里出问题了、谢谢啦!!!
这是创建异步对象的代码
function createXhr() {
            var xhobj = false;
            try {
                xhobj = new ActiveXObject("Msxml2.XMLHTTP"); // ie msxml3.0+
            } catch (e) {
                try {
                    xhobj = new ActiveXObject("Microsoft.XMLHTTP"); //ie msxml2.6
                } catch (e2) {
                    xhobj = false;
                }
            }
            if (!xhobj && typeof XMLHttpRequest != 'undefined') {// Firefox, Opera 8.0+, Safari
                xhobj = new XMLHttpRequest();
            }
            return xhobj;
        }
ajax