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,15 +631,23 @@ jQuery.extend({ ...@@ -631,15 +631,23 @@ jQuery.extend({
ival = null; ival = null;
} }
var status; var status = isTimeout == "timeout" && "timeout" ||
try {
status = isTimeout == "timeout" && "timeout" ||
!jQuery.httpSuccess( xml ) && "error" || !jQuery.httpSuccess( xml ) && "error" ||
s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
"success"; "success";
if ( status == "success" ) {
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.httpData( xml, s.dataType );
} catch(e) {
status = "parsererror";
}
}
// Make sure that the request was successful or notmodified // Make sure that the request was successful or notmodified
if ( status != "error" && status != "timeout" ) { if ( status == "success" ) {
// Cache Last-Modified header, if ifModified mode. // Cache Last-Modified header, if ifModified mode.
var modRes; var modRes;
try { try {
...@@ -649,9 +657,6 @@ jQuery.extend({ ...@@ -649,9 +657,6 @@ jQuery.extend({
if ( s.ifModified && modRes ) if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes; jQuery.lastModified[s.url] = modRes;
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.httpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data // If a local callback was specified, fire it and pass it the data
if ( s.success ) if ( s.success )
s.success( data, status ); s.success( data, status );
...@@ -661,10 +666,6 @@ jQuery.extend({ ...@@ -661,10 +666,6 @@ jQuery.extend({
jQuery.event.trigger( "ajaxSuccess", [xml, s] ); jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else } else
jQuery.handleError(s, xml, status); jQuery.handleError(s, xml, status);
} catch(e) {
status = "parsererror";
jQuery.handleError(s, xml, status, e);
}
// 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