How do I handle 500 errors when using jQuery's getJSON?
There have been a couple of questions about error handling with getJSON()
and JSONP, but I'm not working with JSONP, just ordinary JSON.
Another answer suggests using .ajaxSetup()
before calling getJSON()
, so I tried this:
$.ajaxSetup({
"error":function() {
alert('Error!');
}});
$.getJSON('/book_results/', function(data) { # etc
But I find that the alert always triggers, even when the result is well-formed.
Any ideas?