If I make a jquery AJAX request which is succesful I get back my JSON data. However, If I make a request and I get somthing other than a 200 response code back, I cannot get back the data in the Jquery call back. I need the data as it has a description about the data.
success: function (data, tst, xhr) {
$.log('XHR OK');
},
error: function (xhr, tst, err) {
$.log('XHR ERROR ' + XMLHttpRequest.status);
},
Any ideas?
Thanks
In the:
error: function (xhr, tst, err) {
$.log('XHR ERROR ' + XMLHttpRequest.status);
},
you can use
error: function (XMLHttpRequest, textStatus, errorThrown) {
$.log('XHR ERROR ' + XMLHttpRequest.status);
return JSON.parse(XMLHttpRequest.responseText);
},
to get the JSON response in in event of an error.
XMLHttpRequest.responseText
Cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With