Skip to content

Instantly share code, notes, and snippets.

@trashhalo
Forked from Integralist/cancelAJAX.js
Last active March 7, 2016 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trashhalo/52d6064f85397ffa529e to your computer and use it in GitHub Desktop.
Save trashhalo/52d6064f85397ffa529e to your computer and use it in GitHub Desktop.
Try to cancel all jQuery AJAX requests currently running
$.xhrPool = [];
$.xhrPool.abortAll = function() {
$.xhrPool.forEach(function(jqXHR) {
jqXHR.abort();
});
};
$.rails.ajax = function(options){
var req = $.ajax(options);
$.xhrPool.push(req);
return req;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment