]> source.dussan.org Git - jquery.git/commitdiff
Ajax: remove "onunload" event handler
authorOleg Gaidarenko <markelog@gmail.com>
Sun, 3 May 2015 10:39:33 +0000 (13:39 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Sun, 3 May 2015 10:58:28 +0000 (13:58 +0300)
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

src/ajax/xhr.js

index ac5bc81d918250dcb64bd9abb864f8a1e67a487e..9c204a8518054938eae67b2cf1a5fa8d7ee7a4f9 100644 (file)
@@ -26,20 +26,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
        // For all other browsers, use the standard XMLHttpRequest object
        createStandardXHR;
 
-var xhrId = 0,
-       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 );
-               }
-       });
-}
+var xhrSupported = jQuery.ajaxSettings.xhr();
 
 // Determine support properties
 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
@@ -57,8 +44,7 @@ if ( xhrSupported ) {
                        return {
                                send: function( headers, complete ) {
                                        var i,
-                                               xhr = options.xhr(),
-                                               id = ++xhrId;
+                                               xhr = options.xhr();
 
                                        // Open the socket
                                        xhr.open(
@@ -115,7 +101,6 @@ if ( xhrSupported ) {
                                                // Was never called and is aborted or complete
                                                if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
                                                        // Clean up
-                                                       delete xhrCallbacks[ id ];
                                                        callback = undefined;
                                                        xhr.onreadystatechange = jQuery.noop;
 
@@ -169,7 +154,7 @@ if ( xhrSupported ) {
                                                callback();
                                        } else {
                                                // Add to the list of active xhr callbacks
-                                               xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
+                                               xhr.onreadystatechange = callback;
                                        }
                                },