Moved unload abort code so that the event is only bound if the xhr transport is used. Fixes #5280.
This commit is contained in:
parent
8c8bd3bf6a
commit
1d1d4fe112
|
@ -10,7 +10,7 @@ var // Next fake timer id
|
||||||
xhrPool = [],
|
xhrPool = [],
|
||||||
|
|
||||||
// #5280: see end of file
|
// #5280: see end of file
|
||||||
xhrUnloadAbortMarker = [];
|
xhrUnloadAbortMarker;
|
||||||
|
|
||||||
|
|
||||||
jQuery.ajax.transport( function( s , determineDataType ) {
|
jQuery.ajax.transport( function( s , determineDataType ) {
|
||||||
|
@ -24,6 +24,26 @@ jQuery.ajax.transport( function( s , determineDataType ) {
|
||||||
|
|
||||||
send: function(headers, complete) {
|
send: function(headers, complete) {
|
||||||
|
|
||||||
|
// #5280: we need to abort on unload or IE will keep connections alive
|
||||||
|
if ( ! xhrUnloadAbortMarker ) {
|
||||||
|
|
||||||
|
xhrUnloadAbortMarker = [];
|
||||||
|
|
||||||
|
jQuery(window).bind( "unload" , function() {
|
||||||
|
|
||||||
|
// Abort all pending requests
|
||||||
|
jQuery.each(xhrs, function(_, xhr) {
|
||||||
|
if ( xhr.onreadystatechange ) {
|
||||||
|
xhr.onreadystatechange( xhrUnloadAbortMarker );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reset polling structure to be safe
|
||||||
|
xhrs = {};
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var xhr = xhrPool.pop() || s.xhr(),
|
var xhr = xhrPool.pop() || s.xhr(),
|
||||||
handle;
|
handle;
|
||||||
|
|
||||||
|
@ -178,19 +198,4 @@ jQuery.ajax.transport( function( s , determineDataType ) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// #5280: we need to abort on unload or IE will keep connections alive
|
|
||||||
jQuery(window).bind( "unload" , function() {
|
|
||||||
|
|
||||||
// Abort all pending requests
|
|
||||||
jQuery.each(xhrs, function(_, xhr) {
|
|
||||||
if ( xhr.onreadystatechange ) {
|
|
||||||
xhr.onreadystatechange( xhrUnloadAbortMarker );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Resest polling structure to be safe
|
|
||||||
xhrs = {};
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
|
Loading…
Reference in a new issue