Quantcast
Channel: Cocos中文社区 - 最新帖子
Viewing all articles
Browse latest Browse all 498481

XMLHttpRequest在native上收不到错误返回

$
0
0

send:function(data)
{
cc.log("send msg to server code->"+code);
cc.log(data);
var xhr = new XMLHttpRequest();
xhr.responseType="arraybuffer";
xhr.open(this.method, this.host+":"+this.port+this.path, true);
var that=this;
xhr.onreadystatechange = function ()
{
if (xhr.readyState == 4)
{
if (xhr.status >= 200 && xhr.status < 400)
{
var response = xhr.response;
}
else
{
cc.log("网络访问发生错误,请检查网络是否畅通11.");
}
that.close(xhr);
}
};
xhr.onerror =function(err){
cc.log("网络访问发生错误,请检查网络是否畅通22.");
};
xhr.ontimeout=function(){
this.close(xhr);
cc.log("网络请求超时,请保证你的网络环境稳定.");
};
xhr.send(da'ta);
},


Viewing all articles
Browse latest Browse all 498481

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>