aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2011-01-13 16:58:16 +0100
committerjaubourg <j@ubourg.net>2011-01-13 16:58:16 +0100
commit57956152d8a9d23ae97ba576b8ec4b63306c8758 (patch)
tree156453a9279324e0ebe2f45e9dd6cd732d80923a /src/ajax
parent667a3b31e6a27cfe3f209765d583bff584ecc2f6 (diff)
downloadjquery-57956152d8a9d23ae97ba576b8ec4b63306c8758.tar.gz
jquery-57956152d8a9d23ae97ba576b8ec4b63306c8758.zip
Removed xhr pooling since failing cross-domain requests leaves the xhr object in an undefined state in Firefox. Also rewrote comments related to the active xhr list so that they make sense.
Diffstat (limited to 'src/ajax')
-rw-r--r--src/ajax/xhr.js27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index 3c3d12493..614bd3a0c 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -1,14 +1,11 @@
(function( jQuery ) {
-var // Next fake timer id
- xhrPollingId = jQuery.now(),
+var // Next active xhr id
+ xhrId = jQuery.now(),
- // Callbacks hashtable
+ // active xhrs
xhrs = {},
- // XHR pool
- xhrPool = [],
-
// #5280: see below
xhrUnloadAbortInstalled;
@@ -42,7 +39,7 @@ jQuery.ajax.transport( function( s , determineDataType ) {
}
// Get a new xhr
- var xhr = xhrPool.pop() || s.xhr(),
+ var xhr = s.xhr(),
handle;
// Open the socket
@@ -74,14 +71,12 @@ jQuery.ajax.transport( function( s , determineDataType ) {
try {
xhr.send( ( s.hasContent && s.data ) || null );
} catch(e) {
- // Store back into pool
- xhrPool.push( xhr );
complete(0, "error", "" + e);
return;
}
// Listener
- callback = function( isAbort ) {
+ callback = function( _ , isAbort ) {
// Was never called and is aborted or complete
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
@@ -94,8 +89,6 @@ jQuery.ajax.transport( function( s , determineDataType ) {
if (handle) {
xhr.onreadystatechange = jQuery.noop;
delete xhrs[ handle ];
- handle = undefined;
- xhrPool.push( xhr );
}
// If it's an abort
@@ -171,18 +164,16 @@ jQuery.ajax.transport( function( s , determineDataType ) {
} else {
- // Listener is externalized to handle abort on unload
- handle = xhrPollingId++;
+ // Add to list of active xhrs
+ handle = xhrId++;
xhrs[ handle ] = xhr;
- xhr.onreadystatechange = function() {
- callback();
- };
+ xhr.onreadystatechange = callback;
}
},
abort: function() {
if ( callback ) {
- callback(1);
+ callback(0,1);
}
}
};