取消或中止Ajax调用在IE 6,7,8Ajax、IE

2023-09-10 21:47:26 作者:旧巷听风

我如何取消一个简单的js调用Ajax而其正在执行?

how can i cancel a simple js ajax call while its being performed?

推荐答案

通常与ajax.abort();但在IE上它不会真的辞职请求:

normally with ajax.abort(); but on IE it wont really quit requesting:

调用中止重置对象; onreadystatechange事件处理程序被除去,并且readyState的改变为0(未初始化)。

Calling abort resets the object; the onreadystatechange event handler is removed, and readyState is changed to 0 (uninitialized).

报价是从Microsoft JavaScript的实况。由此我想这在很大程度上取决于浏览器的实现究竟是怎么回事。大多数的浏览器可能会尝试完成正常 - 这样的连接可能仍然达到了一段时间,直到最终收 - 但是那只是一种猜测

the quote is from the Microsoft javascript docu. From this I guess it highly depends on the browser implementation what exactly is going on. most browser will probably try to finish gracefully - thus the connections might still be up for some time until finally closed - but thats just a guess.

(另见http://stackoverflow.com/questions/1287971/aborting-a-jquery-getjson-xmlhtt$p$pquest )