git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bed759c
)
Provided detailed message for JSON parse errors. Fixes #4435.
author
Mike Alup
<malsup@gmail.com>
Mon, 25 Jan 2010 23:48:52 +0000
(18:48 -0500)
committer
jeresig
<jeresig@gmail.com>
Mon, 25 Jan 2010 23:48:52 +0000
(18:48 -0500)
src/ajax.js
patch
|
blob
|
history
test/unit/ajax.js
patch
|
blob
|
history
diff --git
a/src/ajax.js
b/src/ajax.js
index
4af502a
..
d0c6752
100644
(file)
--- a/
src/ajax.js
+++ b/
src/ajax.js
@@
-417,13
+417,16
@@
jQuery.extend({
"notmodified" :
"success";
"notmodified" :
"success";
+ var errMsg;
+
if ( status === "success" ) {
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
data = jQuery.httpData( xhr, s.dataType, s );
if ( status === "success" ) {
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
data = jQuery.httpData( xhr, s.dataType, s );
- } catch(e) {
+ } catch(err) {
status = "parsererror";
status = "parsererror";
+ errMsg = err;
}
}
}
}
@@
-434,7
+437,7
@@
jQuery.extend({
success();
}
} else {
success();
}
} else {
- jQuery.handleError(s, xhr, status);
+ jQuery.handleError(s, xhr, status, errMsg);
}
// Fire the complete handlers
}
// Fire the complete handlers
diff --git
a/test/unit/ajax.js
b/test/unit/ajax.js
index
195fa27
..
f6809d5
100644
(file)
--- a/
test/unit/ajax.js
+++ b/
test/unit/ajax.js
@@
-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." );
start();
},
ok( false, "Success." );
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();
}
});