title: Ajax onerror handler not working
body: <p>In pure Javascript: I make an AJAX request.</p>
  
  <p>The server is supposed to return a 410 error.</p>
  
  <p>My code:</p>
  
  <pre><code>var ajax = new XMLHttpRequest();
  ajax.onload = displayXML;
  ajax.onerror = displayError;
  ajax.open('GET', 'http://myurl.com/request?param=1&amp;param=2', true);
  ajax.send();
  
  function displayError(e) {
      console.log(this.status);
  }
  
  function displayXML() {
      console.log(this.responseXML);
  }
  </code></pre>
  
  <p>Problem is, the <code>onerror</code> function never gets called even when a HTTP 410 is returned. My console says that "GET .... 410 (Gone)" on the line which <code>ajax.send()</code> appears, but then it calls <code>displayPopularity</code>. How should I handle HTTP errors, if I can't use <code>.onerror</code>? I mean, I could just roll the error handling into <code>displayPopularity</code> but I thought there was a more elegant solution.</p>