Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#13756 closed bug (notabug)

Empty JSON respone

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


Sorry my bad English.

If ajax respone is empty, then

541 string - parseJSON()

return window.JSON.parse( data )

SyntaxError: JSON.parse: unexpected end of data (Firefox 19.0.2)

Change History (7)

comment:2 Changed 9 years ago by Rick Waldron

Owner: set to alex[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 the appropriate boilerplate:

Open the link and click to "Fork" (in the top menu) to begin.

Also, please read:

Additional resources:

comment:3 Changed 9 years ago by m_gol

Resolution: notabug
Status: pendingclosed

This has nothing to do with jQuery. An empty string is not valid JSON, hence the error.

comment:4 Changed 8 years ago by dmethvin

#14533 is a duplicate of this ticket.

comment:5 Changed 8 years ago by [email protected]

Whilst it's not valid JSON, it's incredibly dense to leave this as it is. It should just fall back to not parsing the response instead of failing completely.

BTW- if you want to leave in the utterly daft behaviour then at *least* add in some way of informing the user of your silly decisions via some exception or whatever.

comment:6 Changed 8 years ago by dmethvin

Open the browser's console. There will be a message there.

comment:7 Changed 8 years ago by [email protected]

Would be nice if JSON.parse("") didn't throw an exception, as when using $.ajax() together with ASP.NET MVC, it is common practice to use 'void' as return type on simple POSTs, which returns an empty string.

Note: See TracTickets for help on using tickets.