Skip to main content

Bug Tracker

Side navigation

#13751 closed bug (notabug)

Opened April 08, 2013 08:15PM UTC

Closed April 15, 2013 05:12PM UTC

Consistant response for ajax for success and failure

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

When attempting to parse JSON returned in a non 200 fashion, i.e. a 400 error, calling the JSON.parse(data) does not work on the failure, while it works on the success version. The work around for the failure is to pass the responseText.

$.post("/someservice", json).done(function(data) {

var response = JSON.parse(data);

DO something


var response = JSON.parse(data.responseText);

Do something


Attachments (0)
Change History (1)

Changed April 15, 2013 05:12PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

If you want a consistent response type, specify it in the call. Otherwise the returned data will be the "intelligent guess" mentioned in the documentation.