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: | alexpts@yandex.ru | Owned by: | alexpts@yandex.ru |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
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 comment:2
owner: | → alexpts@yandex.ru |
---|---|
status: | new → pending |
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:
- jQuery 1.x http://jsfiddle.net/FrKyN/
- jQuery 2.x http://jsfiddle.net/VUp3e/
Open the link and click to "Fork" (in the top menu) to begin.
Also, please read:
- http://blog.jquery.com/2013/03/01/jquery-2-0-beta-2-released/
- http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/
Additional resources:
- Won't Fix: http://contribute.jquery.org/wont-fix/
- CLA: http://contribute.jquery.org/CLA/
- Style Guide: http://contribute.jquery.org/style-guide/js/
Changed April 14, 2013 10:39PM UTC by comment:3
resolution: | → notabug |
---|---|
status: | pending → closed |
This has nothing to do with jQuery. An empty string is not valid JSON, hence the error.
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 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.
http://jsfiddle.net/hzXyE/1/