紧紧
紧紧
  • 发布:2020-11-25 18:26
  • 更新:2023-02-13 20:29
  • 阅读:805

new plus.net.XMLHttpRequest();对象请求网络返回数据不完整

分类:HTML5+

function(backfun, model, action, cmdkey, cmdtxt, timeout) {
var xhttp = new plus.net.XMLHttpRequest();
window.xmlhttpTimeoutHd = setTimeout(function(){
clearTimeout(app_net_wait_thwnd);
if(!xhttp) { return }
var fun = xhttp.onreadystatechange;
xhttp.onreadystatechange = null;
xhttp.abort();
xhttp.readyStateX = 4;
xhttp.responseTextX = "连接超时";
if(fun){ fun();}
xhttp = null;
},timeout);

      xhttp.open("POST",__app_net_url, true);  
      app.net.xhttpstate = 1;  
      xhttp.onreadystatechange = function() {  
       if(xhttp.readyState==4 || xhttp.readyStateX==4) {   
          app.net.xhttpstate = 0;  
          app.net.WaitMessage = "";  
          __app_net_backdata = (xhttp.readyStateX==4 ? xhttp.responseTextX : xhttp.responseText);  
          __app_net_backdata = null;  
         xhttp.abort();  
         xhttp = null;   
      }else{  
        //console.log("请求监控2[" + (new Date()) + "]:" + xhttp.responseText);  
  }  
 }  

}
更新最新版iOS的sdk后,把项目里所有网络请求对象由new XMLHttpRequest()替换成new plus.net.XMLHttpRequest()才能进行跨域请求数据,但是xhttp.readyState的值只会变化到3而不是4,导致接口返回数据过多时只接收到一部分数据,我项目里一些页面使用旧版sdk正常显示数据加载正常,现在一些页面就是因为网络接口请求得不到完整的数据无法正常加载和渲染,为什么xhttp.readyState状态值始终到不了4!谁来救救我,这个问题真的很头大

2020-11-25 18:26 负责人:无 分享
已邀请:
黄大狗

黄大狗

我遇到的问题也是xhttp.readyState值始终没有4,接口那边又提示无效的json,Error: Invalid JSON RPC response: {"type":"default","status":200,"ok":true,"statusText":"OK"} 有好的解决方法吗?h5又是正常的,在app端就返回不了信息,是因为传过去的json格式不对吗?

要回复问题请先登录注册