Skip to content

Commit 4632e55

Browse files
committed
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 a117dd0
1 parent 0fc5beb commit 4632e55

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/ajax/xhr.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
2626
// For all other browsers, use the standard XMLHttpRequest object
2727
createStandardXHR;
2828

29-
var xhrId = 0,
30-
xhrCallbacks = {},
31-
xhrSupported = jQuery.ajaxSettings.xhr();
32-
33-
// Support: IE<10
34-
// Open requests must be manually aborted on unload (#5280)
35-
// See https://support.microsoft.com/kb/2856746 for more info
36-
if ( window.attachEvent ) {
37-
window.attachEvent( "onunload", function() {
38-
for ( var key in xhrCallbacks ) {
39-
xhrCallbacks[ key ]( undefined, true );
40-
}
41-
});
42-
}
29+
var xhrSupported = jQuery.ajaxSettings.xhr();
4330

4431
// Determine support properties
4532
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
@@ -57,8 +44,7 @@ if ( xhrSupported ) {
5744
return {
5845
send: function( headers, complete ) {
5946
var i,
60-
xhr = options.xhr(),
61-
id = ++xhrId;
47+
xhr = options.xhr();
6248

6349
// Open the socket
6450
xhr.open(
@@ -115,7 +101,6 @@ if ( xhrSupported ) {
115101
// Was never called and is aborted or complete
116102
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
117103
// Clean up
118-
delete xhrCallbacks[ id ];
119104
callback = undefined;
120105
xhr.onreadystatechange = jQuery.noop;
121106

@@ -169,7 +154,7 @@ if ( xhrSupported ) {
169154
callback();
170155
} else {
171156
// Add to the list of active xhr callbacks
172-
xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
157+
xhr.onreadystatechange = callback;
173158
}
174159
},
175160

0 commit comments

Comments
 (0)