I'm writing a REST api. It returns a header status 400 on error.
However, on the AJAX side, I couldn't get the jqxhr object returned.
$.get('site.php', function(data, status, jqxhr) function(data) {
//...
}).error(console.log(jqxhr));
it returns Uncaught ReferenceError: jqxhr is not defined
.
In inspector console, its showing 400 (Bad Request) for the get request.
How do I get the text Bad Request?
I could return the text error within data by passing it in header status 200, but that's not the right approach am I correct?