【发布时间】:2014-08-20 03:40:02
【问题描述】:
我无法在 3 秒后创建 ajax 错误回调函数。我尝试了超时,但它不会在指定时间后切换到错误回调!我无法收到警报Got timeout。
当我在这个网站上提到类似问题时,它并没有帮助。他们都使用 ajax GET 类型。我正在使用 jquery 1.10.1 库。
脚本:
$.ajax({
type: 'POST',
timeout: 3000,
url : "http://mydomain/Services.asmx/Best_Scores",
dataType: "text",
async:false,
crossDomain:true,
data: "strJsonRequest="+scoredata,
success: function (data) {
// Success code ...
},
error: function (data, textStatus, errorThrown) {
if(textStatus == "timeout") {
alert("Got timeout");
}
}
});
有什么办法吗?
【问题讨论】:
-
RTT 到
http://mydomain/Services.asmx/Best_Scores需要多长时间?也许网址根本不会超时? -
@Amberlamps : 谢谢回复,我需要 15-20 秒!
-
您是否尝试在错误函数中警告 if 语句中没有的内容?也许
textStatus不是“超时”?!
标签: javascript jquery ajax html