Skip to content

Commit a117dd0

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
1 parent 9db9316 commit a117dd0

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
@@ -10,9 +10,7 @@ jQuery.ajaxSettings.xhr = function() {
1010
} catch ( e ) {}
1111
};
1212

13-
var xhrId = 0,
14-
xhrCallbacks = {},
15-
xhrSuccessStatus = {
13+
var xhrSuccessStatus = {
1614
// file protocol always yields status code 0, assume 200
1715
0: 200,
1816
// Support: IE9
@@ -21,17 +19,6 @@ var xhrId = 0,
2119
},
2220
xhrSupported = jQuery.ajaxSettings.xhr();
2321

24-
// Support: IE9
25-
// Open requests must be manually aborted on unload (#5280)
26-
// See https://support.microsoft.com/kb/2856746 for more info
27-
if ( window.attachEvent ) {
28-
window.attachEvent( "onunload", function() {
29-
for ( var key in xhrCallbacks ) {
30-
xhrCallbacks[ key ]();
31-
}
32-
});
33-
}
34-
3522
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
3623
support.ajax = xhrSupported = !!xhrSupported;
3724

@@ -43,8 +30,7 @@ jQuery.ajaxTransport(function( options ) {
4330
return {
4431
send: function( headers, complete ) {
4532
var i,
46-
xhr = options.xhr(),
47-
id = ++xhrId;
33+
xhr = options.xhr();
4834

4935
xhr.open(
5036
options.type,
@@ -84,7 +70,6 @@ jQuery.ajaxTransport(function( options ) {
8470
callback = function( type ) {
8571
return function() {
8672
if ( callback ) {
87-
delete xhrCallbacks[ id ];
8873
callback = xhr.onload = xhr.onerror = null;
8974

9075
if ( type === "abort" ) {
@@ -117,7 +102,7 @@ jQuery.ajaxTransport(function( options ) {
117102
xhr.onerror = callback("error");
118103

119104
// Create the abort callback
120-
callback = xhrCallbacks[ id ] = callback("abort");
105+
callback = callback("abort");
121106

122107
try {
123108
// Do send the request (this may raise an exception)

0 commit comments

Comments
 (0)