title: jQuery: handle errors in getJSON()?
body: <p>How do I handle 500 errors when using jQuery's <a href="http://api.jquery.com/jQuery.getJSON/" rel="nofollow noreferrer">getJSON</a>?</p>
  
  <p>There have been a couple of questions about error handling with <code>getJSON()</code> <a href="https://stackoverflow.com/questions/1740218/error-handling-in-getjson-calls">and</a> <a href="https://stackoverflow.com/questions/309953/how-do-i-catch-jquery-getjson-or-ajax-with-datatype-set-to-jsonp-error-wh">JSONP</a>, but I'm not working with JSONP, just ordinary JSON.</p>
  
  <p><a href="https://stackoverflow.com/questions/572991/jquery-getjson-doesnt-trigger-callback/573044#573044">Another answer</a> suggests using <code>.ajaxSetup()</code> before calling <code>getJSON()</code>, so I tried this:</p>
  
  <pre><code>$.ajaxSetup({
    "error":function() {   
      alert('Error!');
  }});
  $.getJSON('/book_results/', function(data) { # etc
  </code></pre>
  
  <p>But I find that the alert always triggers, even when the result is well-formed.</p>
  
  <p>Any ideas?</p>