How to get the jQuery $.ajax error response text?
As ultimately suggested by this other answer and it's comments on this page:
error: function(xhr, status, error) {
var err = JSON.parse(xhr.responseText);
alert(err.Message);
}
Try:
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
For me, this simply works:
error: function(xhr, status, error) {
alert(xhr.responseText);
}
Look at the responseText
property of the request parameter.