Created
November 3, 2011 11:17
-
-
Save Integralist/1336279 to your computer and use it in GitHub Desktop.
Try to cancel all jQuery AJAX requests currently running
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
$.xhrPool = []; | |
$.xhrPool.abortAll = function() { | |
/* Original example used _underscore api | |
_.each(this, function(jqXHR) { | |
jqXHR.abort(); | |
}); | |
*/ | |
$.each(this, function(jqXHR) { | |
jqXHR.abort(); | |
}); | |
}; | |
$.ajaxSetup({ | |
beforeSend: function(jqXHR) { | |
$.xhrPool.push(jqXHR); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Better to use independent code.....