// Callbacks hashtable
xhrs = {},
+ // XHR pool
+ xhrPool = [],
+
// #5280: see end of file
xhrUnloadAbortMarker = [];
send: function(headers, complete) {
- var xhr = s.xhr(),
+ var xhr = xhrPool.pop() || s.xhr(),
handle;
// Open the socket
try {
xhr.send( ( s.hasContent && s.data ) || null );
} catch(e) {
+ // Store back in pool
+ xhrPool.push( xhr );
complete(0, "error", "" + e);
return;
}
if ( callback && ( abortStatusText || xhr.readyState === 4 ) ) {
// Do not listen anymore
+ // and Store back in pool
if (handle) {
xhr.onreadystatechange = jQuery.noop;
delete xhrs[ handle ];
handle = undefined;
+ xhrPool.push( xhr );
}
callback = 0;
status
);
- // Guess response if needed & update datatype accordingly
- if ( status >= 200 && status < 300 ) {
- response =
- determineDataType(
- s,
- xhr.getResponseHeader("content-type"),
- xhr.responseText,
- xhr.responseXML );
- }
+ // Guess response & update dataType accordingly
+ response =
+ determineDataType(
+ s,
+ xhr.getResponseHeader("content-type"),
+ xhr.responseText,
+ xhr.responseXML );
}
// Call complete