Bug Tracker

Opened 10 years ago

Closed 9 years ago

#13430 closed bug (duplicate)

Error in parseJSON:

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: None
Component: ajax Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


I had to update code to fix this issue for me.

LIne 548 in jquery-1.9.1.js Error in IE 10: Invalid character

Added check for null & undefined before calling window.JSON

if (data === null
data === undefined) {

return data;


Attempt to parse using the native JSON parser first if ( window.JSON && window.JSON.parse ) {

return window.JSON.parse( data );



Change History (11)

comment:1 Changed 10 years ago by Rick Waldron

#13431 is a duplicate of this ticket.

comment:2 Changed 10 years ago by Rick Waldron

Owner: set to [email protected]
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists—you may need to change this to a specific version depending on the test case.

To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.

Also, please read: http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/

comment:3 Changed 10 years ago by katafrakt

It's really as simple as typing




in web console (of Chrome 24.0.1312.57 m or Firefox 21.0a1, both on Windows in my case). Edge and 1.9.0 are affected.

comment:4 Changed 10 years ago by dmethvin

Resolution: notabug
Status: pendingclosed

Ok then, there is your problem. An empty string or undefined are not valid JSON. The jQuery Migrate plugin catches these things for you, and will even fix them if you don't want to change code right now:


comment:5 Changed 10 years ago by katafrakt

Ok, but API docs still state:

"Additionally if you pass in nothing, an empty string, null, or undefined, 'null' will be returned from parseJSON."

Which is kind of misleading.

comment:6 Changed 10 years ago by dmethvin

Agreed. There's a docs ticket open to fix that. Note that it does say the method takes a string, and that it takes a JSON string. Unfortunately someone documented the incorrect behavior at some point.

comment:7 Changed 10 years ago by Rick Waldron

#13630 is a duplicate of this ticket.

comment:8 Changed 10 years ago by Alexpts <[email protected]…>

Is not bug jQuery.

if ( window.JSON && window.JSON.parse ) {
	JSON.parse_original = JSON.parse;
	JSON.parse = function(data){
		return (data == "") ? {} : JSON.parse_original(data);

comment:9 Changed 9 years ago by dmethvin

#14360 is a duplicate of this ticket.

comment:10 Changed 9 years ago by gibson042

Resolution: notabug
Status: closedreopened

comment:11 Changed 9 years ago by gibson042

Component: unfiledajax
Resolution: duplicate
Status: reopenedclosed

Duplicate of #13169.

Note: See TracTickets for help on using tickets.