我收到了一个无法复制的bug报告,但ajax调用超时是目前最好的猜测。
因此,我正在尝试找出jQuery $.ajax()
调用的超时的默认值。有谁有主意吗?在jQuery文档中找不到它。
提前谢谢你,马库斯
发布于 2012-11-08 07:19:26
顺便说一句,当我试图诊断一个类似的bug时,我意识到如果jquery的ajax错误回调由于超时而失败,它将返回" timeout“状态。
下面是一个例子:
$.ajax({
url: "/ajax_json_echo/",
timeout: 500,
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus); // this will be "timeout"
}
});
发布于 2014-07-24 12:29:25
默认情况下,没有超时。
发布于 2021-06-17 00:48:36
请参考此接口信息。
timeout
Type: Number
Set a timeout (in milliseconds) for the request. A value of 0 means there
will be no timeout. This will override any global timeout set with
$.ajaxSetup(). The timeout period starts at the point the $.ajax call is made;
if several other requests are in progress and the browser has no connections
available, it is possible for a request to time out before it can be sent. In
jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if
the request times out; accessing any object members may throw an exception. In
Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout;
the script will run even if it arrives after the timeout period.
https://stackoverflow.com/questions/2507355
复制相似问题