Opened 10 years ago
Closed 10 years ago
#13350 closed bug (notabug)
jQuery ajax PUT call results in error when the server response is in JSON and empty string
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | git |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery ajax PUT call results in error when the server response is in JSON and empty string
- The version(s) of jQuery affected: 1.9.0 The previous version of jQuery works as can bee seen in the provided test case.
- The browser: chrome Version 24.0.1312.56, but browser doesn't matter
- The operating system: MacOS, does not need to do anything
- A description of what you expect to happen:
The following ajax call results in error, in previous version of jQuery, they don't result in error. It should not result in error because the HTTP response is 200.
[start reproduce code]
$.ajax({ type: "PUT", url: 'https://taru.zeeses.com:8443/map/jquerybug.jsp', error: function() { alert('ERROR you should not see this, but you see this in 1.9.0'); }, success: function() { alert('SUCCESS this does not work in 1.9.0, but you see it works in 1.8.3 and bellow'); } });
[end reproduce code]
[begin jquerybug.jsp]
<% response.setContentType("text/json"); %>
[end jquerybug.jsp]
Similar ticket, I think similar cause, but it is different case: http://bugs.jquery.com/ticket/13292
Reproducible test case is also saved in: http://jsfiddle.net/ceCqV/5/
Change History (4)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:3 Changed 10 years ago by
Status: | pending → new |
---|
Yes, that is exactly the case, since it's documented, let's close as not a bug.
comment:4 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
Sounds like this case: http://jquery.com/upgrade-guide/1.9/#jquery-ajax-returning-a-json-result-of-an-empty-string
Can you confirm?
That is not the sole criteria of whether the success/error handler is called. If the data type is JSON, the JSON returned must be valid.
Since
JSON.parse("")
(an empty string) is an error, this change just aligns the AJAX processing with that result.If you want a successful JSON result of
null
, return a response body with the four charactersnull
.