1
我正在使用一个iPhone 5S,与iOS版本8.1。当我调试我的Web应用程序有一些jQuery Ajax调用时,我一直在执行我的error
回调方法。我也试图指定超时到一个高值(如20,000毫秒),如下所示:
$.ajax({
type: "POST",
url: serviceURL,
data: userInputjson,
contentType: "application/json; charset=utf-8",
datatype: "json",
async: false,
timeout: 20000,
complete: function (msg) {
if(msg.responseJSON) {
msg = msg.responseJSON;
alert('msg.responseJSON exists');
console.log(msg);
if (msg.Status == 'SUCCESS') {
var obj = JSON.parse(userInputjson);
var firstName,lastName,email;
for(i=0; i< obj.fields.length; i++){
if(obj.fields[i].Key =="FirstName")
{
firstName = obj.fields[i].Value;
}else if(obj.fields[i].Key =="LastName"){
lastName = obj.fields[i].Value;
}else if(obj.fields[i].Key =="Email"){
email = obj.fields[i].Value;
}
}
alert("before cookie");
$.cookie(DHLoginCookieName, {
firstName: firstName,
lastName: lastName,
emial:email,
isLoggedIn: true
});
alert("after cookie");
window.top.location.href = "thankyou.html";
}
else
{
alert("in else");
$(".regLoader").hide();
$("#submiterror").show();
}
return false;
}
},
error: function (xmlHttpRequest, textStatus, errorThrown) {alert("Error status 2: "+textStatus+"\n"+errorThrown);
if (xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0) {
$(".regLoader").hide();
$("#submiterror").show();
return ;
}
}
})
没有任何效果,无论如何。
有人请告诉我可能是我的错。
没有看到AJAX请求的代码,您收到任何错误,可能是服务器端的代码,没有人会能够帮助你从你发布的小信息 –
我明白。其实,web服务代码有点庞大。 –
顺便说一句,你不能设置“async:false:call”的超时时间,jQuery $ .ajax中的代码阻止了它 - 我认为这是某种标准 – PandaWood