如何检测如果一个请求被中止? [英] How to detect if a request was aborted?
本文介绍了如何检测如果一个请求被中止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提出一个请求,然后之后我就放弃。
I am making a request and then right after it I abort.
var x = $.get(url, function (d, e, xhr) { alert(d); });
x.abort();
现在的问题是,它执行成功
函数,并返回空数据...... (例如这里)
The problem is that it executes the success
function and returns empty data... (example here)
有一个jQuery的方法来终止?或者有没有一种方法来检查 XHR
中止?
Is there a jQuery method to abort? or Is there a way to check if the xhr
was aborted?
推荐答案
我发现<一href="http://forum.jquery.com/topic/no-more-ajax-error-callbacks-fired-in-jq1-4-2-jq1-3-2-works-fine">here该 XHR
将状态恢复 0
。似乎是一个jQuery 1.4+错误。在1.3叫错误处理程序。
I found here that the xhr
will return with status 0
. Seems to be a jQuery 1.4+ bug. On 1.3 it called the error handler.
这篇关于如何检测如果一个请求被中止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文