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)
This commit is contained in:
parent
05d401dd84
commit
f64eb21fad
|
@ -631,41 +631,42 @@ 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";
|
|
||||||
|
|
||||||
// Make sure that the request was successful or notmodified
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
if ( status == "success" ) {
|
||||||
|
// Watch for, and catch, XML document parse errors
|
||||||
|
try {
|
||||||
// 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) {
|
||||||
// If a local callback was specified, fire it and pass it the data
|
status = "parsererror";
|
||||||
if ( s.success )
|
}
|
||||||
s.success( data, status );
|
|
||||||
|
|
||||||
// Fire the global callback
|
|
||||||
if( s.global )
|
|
||||||
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
|
|
||||||
} else
|
|
||||||
jQuery.handleError(s, xml, status);
|
|
||||||
} catch(e) {
|
|
||||||
status = "parsererror";
|
|
||||||
jQuery.handleError(s, xml, status, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 ( s.ifModified && modRes )
|
||||||
|
jQuery.lastModified[s.url] = modRes;
|
||||||
|
|
||||||
|
// If a local callback was specified, fire it and pass it the data
|
||||||
|
if ( s.success )
|
||||||
|
s.success( data, status );
|
||||||
|
|
||||||
|
// Fire the global callback
|
||||||
|
if( s.global )
|
||||||
|
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
|
||||||
|
} else
|
||||||
|
jQuery.handleError(s, xml, status);
|
||||||
|
|
||||||
// The request was completed
|
// The request was completed
|
||||||
if( s.global )
|
if( s.global )
|
||||||
jQuery.event.trigger( "ajaxComplete", [xml, s] );
|
jQuery.event.trigger( "ajaxComplete", [xml, s] );
|
||||||
|
|
Loading…
Reference in a new issue