I am using jQuery Tabs for my project, with “lazy” loading tab content via Ajax.
But, when I do a typo and Rails framework gives me HTTP 404 with error page, Tab will not load the page and I can’t see the error information. (Correction: Rails seems to return HTTP 500, when there is a typo in the code)
Is there a way to tell jQuery to load/display pages returned with 404 code like normal?
I’ve got this far:
$('#tabs').tabs({
ajaxOptions: {
error: function (xhr, status, err) {
// Call success function - but how?
}
}
});
The ajaxOptions object takes the same options as the actual jQuery .ajax() method, so you can use the statusCode object to your advantage here http://api.jquery.com/jQuery.ajax/
The example on that page for the statusCode looks like this:
To use it in the jQuery Tabs context, just pass statusCode as an object into the ajaxOptions like this: