title: Handling API http return errors on JQuery
body: <p>I have this html page:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
  
    $.ajax({
      url: "https://api.github.com/users/Microsoft/",
      type: 'GET',
      dataType: 'json',
      success: function(res) {
        $('#result').text(JSON.stringify(res, null, '\n'));
      }.error: function(jqXHR, error, errorThrown) {
        if (jqXHR.status &amp;&amp; jqXHR.status == 400) {
          alert(jqXHR.responseText);
        } else {
          alert("Something went wrong");
        }
      }
    });
  
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="container"&gt;
    &lt;pre id="result" style="color:red"&gt;&lt;/pre&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If Take away this:</p>
  
  <pre><code>.error: function(jqXHR,error, errorThrown) {  
             if(jqXHR.status&amp;&amp;jqXHR.status==400){
                 alert(jqXHR.responseText); 
             }else{
                 alert("Something went wrong");
             }
  </code></pre>
  
  <p>The result is shown properly, right now, it doesn't show anything. Just a blank page.</p>
  
  <p>What I want, is to handle some http error that could happen if the API response isn't successful.</p>
  
  <p>Any ideas?</p>