Provided detailed message for JSON parse errors. Fixes #4435.
This commit is contained in:
parent
bed759c95c
commit
ca90ffb332
2 changed files with 8 additions and 4 deletions
|
@ -417,13 +417,16 @@ jQuery.extend({
|
||||||
"notmodified" :
|
"notmodified" :
|
||||||
"success";
|
"success";
|
||||||
|
|
||||||
|
var errMsg;
|
||||||
|
|
||||||
if ( status === "success" ) {
|
if ( status === "success" ) {
|
||||||
// Watch for, and catch, XML document parse errors
|
// Watch for, and catch, XML document parse errors
|
||||||
try {
|
try {
|
||||||
// process the data (runs the xml through httpData regardless of callback)
|
// process the data (runs the xml through httpData regardless of callback)
|
||||||
data = jQuery.httpData( xhr, s.dataType, s );
|
data = jQuery.httpData( xhr, s.dataType, s );
|
||||||
} catch(e) {
|
} catch(err) {
|
||||||
status = "parsererror";
|
status = "parsererror";
|
||||||
|
errMsg = err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +437,7 @@ jQuery.extend({
|
||||||
success();
|
success();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jQuery.handleError(s, xhr, status);
|
jQuery.handleError(s, xhr, status, errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire the complete handlers
|
// Fire the complete handlers
|
||||||
|
|
|
@ -892,7 +892,7 @@ test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.ajax() - malformed JSON", function() {
|
test("jQuery.ajax() - malformed JSON", function() {
|
||||||
expect(1);
|
expect(2);
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
|
@ -903,8 +903,9 @@ test("jQuery.ajax() - malformed JSON", function() {
|
||||||
ok( false, "Success." );
|
ok( false, "Success." );
|
||||||
start();
|
start();
|
||||||
},
|
},
|
||||||
error: function(xhr, msg) {
|
error: function(xhr, msg, detailedMsg) {
|
||||||
equals( "parsererror", msg, "A parse error occurred." );
|
equals( "parsererror", msg, "A parse error occurred." );
|
||||||
|
ok( /^Invalid JSON/.test(detailedMsg), "Detailed parsererror message provided" );
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue