jquery: JQuery trying to parse a 204 No content response
When I do an Ajax request and the server return an 204 No content response JQuery (v1.11.3) try to parse the content and I get this error: JQMIGRATE: jQuery.parseJSON requires a valid JSON string (json = "")
. I don’t know if it’s the cause but the response I got from the server does have:
Content-Length: 4
Content-Type: application/json
It’s an error from the server but HTTP spec say that a 204 code mean that there’s no content so JQuery mustn’t try to parse a 204 response.
Here’s how I was used JQuery:
$.ajax({
url: 'myurl',
type: 'DELETE',
headers: {'Accept':'application/json'},
});
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19 (11 by maintainers)
The HTTP spec say that an HTTP 204 doesn’t have a body so jQuery must not try to parse it. But if it’s a feature I can live with it. It just jQuery doesn’t respect the HTTP spec, that the problem.