title: jquery ajax custom error handler
body: <p>I am writing an backbone js web app on top of an JSON server that returns JSON responses in J<a href="http://labs.omniti.com/labs/jsend" rel="nofollow">Send specification format</a>. </p>
  
  <p>Here are a few examples of that format:</p>
  
  <p><strong>GET /posts</strong></p>
  
  <pre><code>{
   "status": "success",
   "data": {
     "posts" [
       {"id": 1, "title": "A blog post"}, 
       {"id": 2, "title": "another blog post"}
     ]
   }
  }
  </code></pre>
  
  <p><strong>POST /posts</strong></p>
  
  <pre><code>{
    "status": "fail",
    "data": {
      "title": "required"
    }
  }
  </code></pre>
  
  <p>By default the "error" event in $.ajax gets triggered by http codes, but since the JSend specification format does not use HTTP codes at all, I have to rewrite the $.ajax error handler.</p>
  
  <p>The way it works by default (http codes):</p>
  
  <pre><code>$.ajax({
    error: function() {
      // Do your job here.
    },
    success: function() {
      // Do your job here.
    }
  });
  </code></pre>
  
  <p>How can I rewrite the $.ajax error handler that it gets triggered when parsed the body and if the "status" property is "fail" or "error"?</p>