Commit dd45c324 authored by jeresig's avatar jeresig

Simplified some of the logic for handling the ajax aborts, making sure that...

Simplified some of the logic for handling the ajax aborts, making sure that ajaxStop isn't called twice.
parent d60b1978
......@@ -390,18 +390,19 @@ jQuery.extend({
// Wait for a response to come back
var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
// The request was aborted, clear the interval and decrement jQuery.active
// The request was aborted
if ( !xhr || xhr.readyState === 0 ) {
// Opera doesn't call onreadystatechange before this point
// so we simulate the call
if ( !requestDone ) {
complete();
}
requestDone = true;
if ( xhr ) {
xhr.onreadystatechange = jQuery.noop;
}
// 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
} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
requestDone = true;
......@@ -456,15 +457,11 @@ jQuery.extend({
xhr.abort = function() {
oldAbort.call( xhr );
if ( !requestDone ) {
complete();
}
if ( xhr ) {
xhr.onreadystatechange = null;
xhr.readyState = 0;
}
requestDone = true;
onreadystatechange();
};
} catch(e) { }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment