AJAX - get response body in success and error
The first param to error handler is jqxhr
, it has the property responseText
which will give the response body.
$.ajax({ type: "POST", url: '/register', data : registerRequestJSON, contentType:"application/json", success: function(data){ $("#register_area").text();// need to show success }, error: function(jqxhr) { $("#register_area").text(jqxhr.responseText); // @text = response error, it is will be errors: 324, 500, 404 or anythings else } });