title: How to handle a 401 unauthorized response with Backbone?
body: <p>I configure my Backbone router with different views. But on some views, I need to fetch a collection. If the user is not logged in, server returns a 401 http status. </p>
  
  <p>So, I configure jQuery's global ajax settings like that:</p>
  
  <pre><code>$.ajaxSetup({
      xhrFields: {
          withCredentials: true
      },
      crossDomain: true,
      error: function(jqXHR, textStatus, errorThrown) {
          console.log("error ajax");
          if (jqXHR.status == 401) {
              console.log('error 401');
              app.router.navigate('', { trigger: true });
          }
      }
  });
  </code></pre>
  
  <p>But it never goes in the error callback, even if the response code is 401.</p>