Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Landing fixes for tickets #2935 and #2688 (Aborting ajax doesn't stop…

… the setInterval, ajaxStop event isn't getting triggered).
  • Loading branch information...
commit 0aa8d40cdfb50fd423a3bdcf585ac27f89df5b97 1 parent 464535e
@jeresig jeresig authored
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/ajax.js
View
19 src/ajax.js
@@ -308,10 +308,11 @@ jQuery.extend({
s.accepts._default );
} catch(e){}
- // Allow custom headers/mimetypes
+ // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
- // cleanup active request counter
- s.global && jQuery.active--;
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
// close opended socket
xhr.abort();
return false;
@@ -322,8 +323,18 @@ jQuery.extend({
// Wait for a response to come back
var onreadystatechange = function(isTimeout){
+ // The request was aborted, clear the interval and decrement jQuery.active
+ if (xhr.readyState == 0) {
+ if (ival) {
+ // clear poll interval
+ clearInterval(ival);
+ ival = null;
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+ }
// The transfer is complete and the data is available, or the request timed out
- if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
+ } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
requestDone = true;
// clear poll interval
Please sign in to comment.
Something went wrong with that request. Please try again.