Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure that a parsererror is thrown whenever malformed JSON comes …
…back from a server (so that the Ajax error handler is called). Makes it uniform across browsers that do and don't have JSON.parse support.
- Loading branch information
Showing
3 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{bad: 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
308d6cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I feel petty , but I had to note that this line in ajax.js (line: 576 ):
Should probably be :
Thanks: DBJ
308d6cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I get it now ... For all modern browsers you are simply passing the data string to JSON.parse() without any checks whatsoever.
Leaving it to the implementers of it to throw exception or not if wrong JSON string has arrived.
Your logic is to simply "pass the bucket" to window.JSON ... So if one wants to have her JSON working in all browsers, the same one should sort out her JSON, first. This is OK logic, of course. Not entirely jQuery "hand holding" style, but OK.
In this case you are actually throwing an exception, which I think you should do much more in jQuery in general ;o)
308d6cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My attempt is here (at the bottom)
http://dbj.org/dbj/?p=470
I had a luxury of mulling over this while You are in a 1.4 releasing frenzy. Maybe You will find it usefull therefore ...
Thanks: DBJ