Reputation: 53786
How can I check what the error value returned is in ajax callback error :
$.ajax({
url: "myurl",
type: 'POST',
dataType : "text",
data : ({
json : myjson
}),
success : function(data) {
},
error : function() {
alert ('error');
}
});
Upvotes: 0
Views: 8219
Reputation: 839
Try accessing these parameters for your error part of the ajax call:
error: function (request, status, error) {
alert(request.responseText);
Another example:
error: function(xhr) {
if(xhr.status == 422) {
alert(parseErrors(xhr));
} else {
alert('An error occurred while processing the request.');
}
They are part of the ajax call you seperate them with a comma. So a little example:
$.ajax({
success: function(data) {
},
error: function(xhr) {
}
});
Update: Basically xhr.status is the http status number.
alert("readyState: "+xhr.readyState);
alert("status: "+xhr.status);
alert("responseText: "+xhr.responseText);
Upvotes: 8
Reputation: 5893
similar to this question
error : function(jqXHR, textStatus, errorThrown){
alert(jqXHR.status);
}
http://api.jquery.com/jQuery.ajax/
Upvotes: 1