Stop all active ajax requests
May 31, 2012     07:18:03

Several months ago I encountered a problem - "How to abort() all current requests on the project page?". If you have a project built on AJAX you'll definitely need this functionality. Moreover, if your project is not built entirely on AJAX, but uses it in some cases to accelerate the navigation on the project you would not have prevented the use of abort() for such requests.

In a single use of AJAX it is simple. The XMLHttpRequest has a abort method, which cancels the request.

// creating our request
xhr = $.ajax({
	url: 'ajax/progress.ftl',
	success: function(data) {
		//do something

// aborting the request

But what if we have a lot of requests and we wand to abort all of them?