Created
June 30, 2011 16:03
-
-
Save Fordi/1056544 to your computer and use it in GitHub Desktop.
Function for killing all running ajax requests in jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var _ajax = $.ajax, | |
xhrQueue = []; | |
$.ajax = function () { | |
var ret; | |
xhrQueue.push(ret=_ajax.apply(this, arguments)); | |
return ret; | |
}; | |
$.ajaxCancel = function () { | |
while (xhrQueue.length>0) xhrQueue.pop().abort(); | |
}; | |
})(jQuery); |
trevnorris
commented
Jun 30, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment