当用ajax的时候,进行到open操作的时候
同步不会有显示网页错误,但是异步就会出现网页出错的问题
这是怎么回事呢

解决方案 »

  1.   

    异步加载延迟的问题,你是不是在ajax的open函数后面使用了通过了ajax加载的数据...
      

  2.   

    那么多开源良好的js框架,为什么不用呢?jquery中那是相当的简单。你的问题是不是获取方式的影响呢?get,post
      

  3.   


    alert("get");
    this.xmlReq.open(this.method, this.url,this.isAsync);
    alert("open");
    this.xmlReq.send(this.data);在这里我使用了这两个alert,当alert("get");之前不会有(网页错误提示)
    但是当open操作之后,即显示alert("open");之后就会有(网页错误提示)
      

  4.   


    this.init = function() {
    var owner = this;
    this.createXMLRequest();//得到XMLHTTP对象
    if(this.isAsync){
    this.xmlReq.onreadystatechange = function() {
    alert("onreadystatechange");
    owner.stateChange.call(owner);//调用stateChange方法,参数为owner
    };
    }
    }上个代码中回调函数通过this.isAsync这个值的真假来判断是否执行this.xmlReq.onreadystatechange,当异步需要执行的时候,在执行了this.xmlReq.open(this.method, this.url,this.isAsync);就网页报错了