mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Added a bunch of fixes for AJAX timeouts, etc. in Safari.
This commit is contained in:
parent
25802e8bd0
commit
874e4f65ee
@ -145,6 +145,8 @@ jQuery.extend({
|
|||||||
if ( ! jQuery.active++ )
|
if ( ! jQuery.active++ )
|
||||||
jQuery.event.trigger( "ajaxStart" );
|
jQuery.event.trigger( "ajaxStart" );
|
||||||
|
|
||||||
|
var requestDone = false;
|
||||||
|
|
||||||
// Create the request object
|
// Create the request object
|
||||||
var xml = new XMLHttpRequest();
|
var xml = new XMLHttpRequest();
|
||||||
|
|
||||||
@ -170,8 +172,10 @@ jQuery.extend({
|
|||||||
// Wait for a response to come back
|
// Wait for a response to come back
|
||||||
var onreadystatechange = function(istimeout){
|
var onreadystatechange = function(istimeout){
|
||||||
// The transfer is complete and the data is available, or the request timed out
|
// The transfer is complete and the data is available, or the request timed out
|
||||||
if ( xml && (xml.readyState == 4 || istimeout) ) {
|
if ( xml && (xml.readyState == 4 || istimeout == "timeout") ) {
|
||||||
var status = jQuery.httpSuccess( xml ) && !istimeout ?
|
requestDone = true;
|
||||||
|
|
||||||
|
var status = jQuery.httpSuccess( xml ) && istimeout != "timeout" ?
|
||||||
ifModified && jQuery.httpNotModified( xml, url ) ? "notmodified" : "success" : "error";
|
ifModified && jQuery.httpNotModified( xml, url ) ? "notmodified" : "success" : "error";
|
||||||
|
|
||||||
// Make sure that the request was successful or notmodified
|
// Make sure that the request was successful or notmodified
|
||||||
@ -221,8 +225,7 @@ jQuery.extend({
|
|||||||
// Cancel the request
|
// Cancel the request
|
||||||
xml.abort();
|
xml.abort();
|
||||||
|
|
||||||
// for Opera. Opera does't call onreadystatechange when aborted.
|
if ( !requestDone ) onreadystatechange( "timeout" );
|
||||||
if (xml) onreadystatechange(1);
|
|
||||||
|
|
||||||
// Clear from memory
|
// Clear from memory
|
||||||
xml = null;
|
xml = null;
|
||||||
@ -239,9 +242,9 @@ jQuery.extend({
|
|||||||
// Determines if an XMLHttpRequest was successful or not
|
// Determines if an XMLHttpRequest was successful or not
|
||||||
httpSuccess: function(r) {
|
httpSuccess: function(r) {
|
||||||
try {
|
try {
|
||||||
return r.status ?
|
return !r.status && location.protocol == "file:" ||
|
||||||
( r.status >= 200 && r.status < 300 ) || r.status == 304 :
|
( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
|
||||||
location.protocol == "file:";
|
jQuery.browser.safari && r.status == undefined;
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -253,7 +256,8 @@ jQuery.extend({
|
|||||||
var xmlRes = xml.getResponseHeader("Last-Modified");
|
var xmlRes = xml.getResponseHeader("Last-Modified");
|
||||||
|
|
||||||
// Firefox always returns 200. check Last-Modified date
|
// Firefox always returns 200. check Last-Modified date
|
||||||
if( xml.status == 304 || xmlRes == jQuery.lastModified[url] ) return true;
|
return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
|
||||||
|
jQuery.browser.safari && xml.status == undefined;
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user