I have the following jQuery submit request:
$.post("ajax.php", data).done( function(response){ // do something when response is ok } ).fail( function(response){ $("#error").html(response); } );
In my ajax.php file, when something goes wrong, I return an HTTP 400 response code with the message:
header("HTTP/1.0 400 Error"); echo "Some error message"; exit();
When I check the response to an error call in my browser, I can see the Status Code:400 Bad Request status code and the response text that I sent in the error message. But jQuery .fail does not display my response .
How can I access the text of the error / error response?
EDIT
I tested my code and the .fail callback .fail , I just can't get the displayed response message.
Gacek source share