I am doing error handling in my.js, where i am having cross domain call to other server, also for dynamic HTML template i am using Mustache.js.
$.getJSON(url, function(data, textStatus, xhr) {
$.each(data, function(i, data) {
introPage(data);
});
}).fail(function(Error) {
alert(Error.status);
});
function introPage(data )
{
$.getJSON('myphp.php?jsoncallback=?&template='+testTemplate, function(msg) {
// my operations
}).error(function(data) {
});
}
We have .fail() in getJSON to catch the errors in getJSON. I am able to catch 404 error (not found) but when it comes to 406 error (not acceptable or say invalid input) or 401 error(unauthorised access), .fail() does not seems to work
but throws the error in console
Also when i click the link. it shows error in jquery callback in below format
jQuery191014790988666936755_1378113963780({
"error": {
"code": 406,
"message": "Not Acceptable: Sorry, There are no results to display for the given input."
}
});
Now i am wondering how to get this error in my JS . i am not getting Error code 406 and 401.I need that error code so that appropriate error page be displayed.
Thank you