Bug Tracker

Opened 7 years ago

Closed 7 years ago

#13751 closed bug (notabug)

Consistant response for ajax for success and failure

Reported by: kevin.d.mccullough@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

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

}).fail(function(data){

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

});

Change History (1)

comment:1 Changed 7 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.