#13756 closed bug (notabug)
Empty JSON respone
Reported by: | Owned by: | ||
---|---|---|---|
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)
Change History (7)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to alexpts@… |
---|---|
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/
comment:3 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | pending → closed |
This has nothing to do with jQuery. An empty string is not valid JSON, hence the error.
comment:5 Changed 10 years ago by
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:7 Changed 10 years ago by
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/