Commit f64eb21f authored by John Resig's avatar John Resig

We were catching exceptions within the success callback of an Ajax request,...

We were catching exceptions within the success callback of an Ajax request, then causing an error callback to be called (which is incorrect). (Bug #1441)
parent 05d401dd
...@@ -631,40 +631,41 @@ jQuery.extend({ ...@@ -631,40 +631,41 @@ jQuery.extend({
ival = null; ival = null;
} }
var status; var status = isTimeout == "timeout" && "timeout" ||
try { !jQuery.httpSuccess( xml ) && "error" ||
status = isTimeout == "timeout" && "timeout" || s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
!jQuery.httpSuccess( xml ) && "error" || "success";
s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
"success"; if ( status == "success" ) {
// Watch for, and catch, XML document parse errors
// Make sure that the request was successful or notmodified try {
if ( status != "error" && status != "timeout" ) {
// Cache Last-Modified header, if ifModified mode.
var modRes;
try {
modRes = xml.getResponseHeader("Last-Modified");
} catch(e) {} // swallow exception thrown by FF if header is not available
if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes;
// process the data (runs the xml through httpData regardless of callback) // process the data (runs the xml through httpData regardless of callback)
var data = jQuery.httpData( xml, s.dataType ); var data = jQuery.httpData( xml, s.dataType );
} catch(e) {
status = "parsererror";
}
}
// Make sure that the request was successful or notmodified
if ( status == "success" ) {
// Cache Last-Modified header, if ifModified mode.
var modRes;
try {
modRes = xml.getResponseHeader("Last-Modified");
} catch(e) {} // swallow exception thrown by FF if header is not available
// If a local callback was specified, fire it and pass it the data if ( s.ifModified && modRes )
if ( s.success ) jQuery.lastModified[s.url] = modRes;
s.success( data, status );
// Fire the global callback // If a local callback was specified, fire it and pass it the data
if( s.global ) if ( s.success )
jQuery.event.trigger( "ajaxSuccess", [xml, s] ); s.success( data, status );
} else
jQuery.handleError(s, xml, status); // Fire the global callback
} catch(e) { if( s.global )
status = "parsererror"; jQuery.event.trigger( "ajaxSuccess", [xml, s] );
jQuery.handleError(s, xml, status, e); } else
} jQuery.handleError(s, xml, status);
// The request was completed // The request was completed
if( s.global ) if( s.global )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment