function submitAjaxData(data,func,url,asyn,toast){
var http=new XMLHttpRequest();
alert("0");//ok 1
if(toast){
var prg = document.getElementById(toast);
alert("x");
if(prg){prg=prg.getElementsByClassName("weui_toast_content");}
if(prg){
var upload=http.upload;
alert("1");
show(toast);
upload.onprogress=function(e){
prg[0].innerHTML = "已完成:" + parseInt(e.loaded/e.total*100) + "%";
}
alert("2");
upload.onload=function(e){
hide(toast);
}
}
}
if (asyn !== false){
http.onreadystatechange =function(){
//http.onload=function(){
alert("123");
if (http.readyState==4 && http.status==200){
alert("11"); //4
eval(func + "(http.responseText)");
alert("12");
}
else{
alert("13");
eval(func + "(http.status.toString())");
}
alert("14");
}
alert("3");//ok 2
http.onerror=function(){
alert("21");
eval(func + "(http.status.toString())");
}
http.open("POST",url);
http.send(data);
alert("4");//ok 3
}
else {
http.open("POST",url,false);
alert("5");
http.send(data);
if (http.readyState==4 && http.status==200){
if(func!=""){eval(func + "(http.responseText)");}
else{return http.responseText}
}
else{
if(func!=""){eval(func + "(http.status.toString())");}
else{return http.status.toString()}
}
}
}
正常手机:
1-3-123-13-14-4-失败提示-123-13-14-123-13-14-123-11-12-14
iphoneX:0-3-123-13-14-4-失败提示
[此贴子已经被作者于2018/6/19 8:36:31编辑过]