Side navigation
#13350 closed bug (notabug)
Opened January 30, 2013 04:06AM UTC
Closed January 30, 2013 01:26PM UTC
jQuery ajax PUT call results in error when the server response is in JSON and empty string
Reported by: | mpermana@hotmail.com | Owned by: | mpermana@hotmail.com |
---|---|---|---|
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
1. The version(s) of jQuery affected: 1.9.0
The previous version of jQuery works as can bee seen in the provided test case.
2. The browser: chrome Version 24.0.1312.56, but browser doesn't matter
3. The operating system: MacOS, does not need to do anything
4. 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:
Attachments (0)
Change History (4)
Changed January 30, 2013 04:12AM UTC by comment:1
Changed January 30, 2013 04:12AM UTC by comment:2
owner: | → mpermana@hotmail.com |
---|---|
status: | new → pending |
Changed January 30, 2013 10:50AM UTC by comment:3
status: | pending → new |
---|
Yes, that is exactly the case, since it's documented, let's close as not a bug.
Changed January 30, 2013 01:26PM UTC by comment:4
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
.