Skip to main content

Bug Tracker

Side navigation

#13756 closed bug (notabug)

Opened April 09, 2013 01:40PM UTC

Closed April 14, 2013 10:39PM UTC

Last modified January 31, 2014 12:28PM UTC

Empty JSON respone

Reported by: Owned by:
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)

Attachments (0)
Change History (7)

Changed April 09, 2013 01:45PM UTC by comment:1

Changed April 09, 2013 02:43PM UTC by rwaldron comment:2

owner: →
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:

Changed April 14, 2013 10:39PM UTC by m_gol comment:3

resolution: → notabug
status: pendingclosed

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

Changed November 12, 2013 11:01PM UTC by dmethvin comment:4

#14533 is a duplicate of this ticket.

Changed November 12, 2013 11:06PM UTC by comment:5

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.

Changed November 12, 2013 11:08PM UTC by dmethvin comment:6

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

Changed January 31, 2014 12:28PM UTC by comment:7

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.