我的服务端是java,请求后服务端返回如下JSON格式的字符串数据: {"aniFrames":[{"frameid":"137","ftime":"200","fwidth":"400","fheight":"400"}] } 但之后就没反应了,我跟了一下,页面就只到了readystate为1的状态,就没有了,请教各位大侠是什么原因呢?

解决方案 »

  1.   


    //代码片段,来自http://www.easyui.org.cn post:function(sUrl,sArgs,bAsync,fCallBack,fFailure){
    var xhr = this.init();
    if(!xhr){alert('XmlHttp对象未就绪!');return;}
    xhr.onreadystatechange = function(){//这里绑定状态更改事件
    if(xhr.readyState == 4){
    if(xhr.status == 200){
    if(fCallBack&&fCallBack.constructor==Function){fCallBack(xhr);}
    }else{
    if(fFailure&&fFailure.constructor==Function){
    fFailure(xhr);
    }else{
    alert('服务器错误:'+xhr.status);
    }
    xhr = null;
    }
    }
    };
    xhr.open('POST',encodeURI(sUrl),bAsync);
    xhr.setRequestHeader('Content-Length',sArgs.length);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(sArgs);