xhrPool = [],
// #5280: see end of file
- xhrUnloadAbortMarker = [];
+ xhrUnloadAbortMarker;
jQuery.ajax.transport( function( s , determineDataType ) {
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(),
handle;
}
});
-// #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 );