Laya版本为2.0,程序中用Laya.HttpRequest的send函数post请求一个地址,在layaair中启动浏览器,可以正常得到回复,但用layaair生成的二维码,通过手机扫描测试,send请求时,就会收到一个error事件,错误提示Request failed Status:0,但服务器却可以收到请求,请问这个怎么解决?下面是代码片段:
let hr = new Laya.HttpRequest();
hr.http.timeout = 5000;
hr.on(Laya.Event.PROGRESS, this, this.onHttpRequestProgress);
hr.once(Laya.Event.COMPLETE, this, (response)=>{
UIFactory.closeWaitBar();
this.onHttpRequestComplete(response);
if(handleOk){
handleOk(response);
}
});
hr.once(Laya.Event.ERROR, this, (e)=>{
UIFactory.closeWaitBar();
this.onHttpRequestError(e);
if(handleFail){
handleFail(e);
}
else{
UIFactory.alertConfirm(LayaWrap.creatHandlerCall(this,()=>{
UIFactory.showWaitBar(LayaWrap.creatHandlerCall(this,()=>{
this.connect(handleOk,handleFail);
}))
}), LocalTxt.getText("请求失败")+":"+e);
}
});
LogUtil.info(this.urlString,this.methodString,this.responseType,this.dataAny);
hr.send(this.urlString, this.dataAny, this.methodString, this.responseType,this.headers);