Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#13459 closed bug (notabug)

Questionable behavior in 1.9.1 with $.ajax.done

Reported by: manchagnu@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:


If I make a request using dataType as "JSON" and the server sends back a "200 ok" with an empty body, my ajax call throws a parser error:

"parsererror", SyntaxError: {message: "Unexpected end of input"}

jQuery 1.8.3 did report a success, 1.9.1 reports a failure.

It is arguable that one is "more correct" than the other. Was this an intentional change? Can this regression be addressed?

Thanks!! Miguel

Change History (2)

comment:1 Changed 11 years ago by dmethvin

Resolution: notabug
Status: newclosed

If dataType: "json" then the server should send back JSON and not an empty body. Version 1.1.1 of the jQuery Migrate plugin will be coming out soon and will let you run the old code without change. Alternate solutions are here:


comment:2 Changed 11 years ago by james@…

This issue also occurs when the response's content type is application/json. In a perfect world, the server would either remove that content-type header or respond with a valid JSON object... but I think it would be beneficial if jQuery could guard against this scenario by not trying to convert an empty response to JSON (as it did before 1.9).

Note: See TracTickets for help on using tickets.