Commit 4632e558 authored by Oleg Gaidarenko's avatar Oleg Gaidarenko

Ajax: remove "onunload" event handler

Remove hack for IE lost connections, update for it was released
by Microsoft at November 12, 2013.
See https://support.microsoft.com/en-us/kb/2905733

Ref trac-5280
Ref gh-2047
Ref a117dd05f638a078c21dc57f19966f4ae81f98f0
parent 0fc5bebb
...@@ -26,20 +26,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? ...@@ -26,20 +26,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
// For all other browsers, use the standard XMLHttpRequest object // For all other browsers, use the standard XMLHttpRequest object
createStandardXHR; createStandardXHR;
var xhrId = 0, var xhrSupported = jQuery.ajaxSettings.xhr();
xhrCallbacks = {},
xhrSupported = jQuery.ajaxSettings.xhr();
// Support: IE<10
// Open requests must be manually aborted on unload (#5280)
// See https://support.microsoft.com/kb/2856746 for more info
if ( window.attachEvent ) {
window.attachEvent( "onunload", function() {
for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ]( undefined, true );
}
});
}
// Determine support properties // Determine support properties
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
...@@ -57,8 +44,7 @@ if ( xhrSupported ) { ...@@ -57,8 +44,7 @@ if ( xhrSupported ) {
return { return {
send: function( headers, complete ) { send: function( headers, complete ) {
var i, var i,
xhr = options.xhr(), xhr = options.xhr();
id = ++xhrId;
// Open the socket // Open the socket
xhr.open( xhr.open(
...@@ -115,7 +101,6 @@ if ( xhrSupported ) { ...@@ -115,7 +101,6 @@ if ( xhrSupported ) {
// Was never called and is aborted or complete // Was never called and is aborted or complete
if ( callback && ( isAbort || xhr.readyState === 4 ) ) { if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
// Clean up // Clean up
delete xhrCallbacks[ id ];
callback = undefined; callback = undefined;
xhr.onreadystatechange = jQuery.noop; xhr.onreadystatechange = jQuery.noop;
...@@ -169,7 +154,7 @@ if ( xhrSupported ) { ...@@ -169,7 +154,7 @@ if ( xhrSupported ) {
callback(); callback();
} else { } else {
// Add to the list of active xhr callbacks // Add to the list of active xhr callbacks
xhr.onreadystatechange = xhrCallbacks[ id ] = callback; xhr.onreadystatechange = callback;
} }
}, },
......
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