title: Automatically try AJAX request again on Fail
body: <p>I have seen that you can specify what to do generally if an ajax request fails, is it possible to have it try again in some sort of a loop so that it tries at least x amount of times before it stops? I have used this code before:</p>
  
  <pre><code>$.ajaxSetup({
    "error":function() {   
      alert("error");
  }});
  </code></pre>
  
  <p>Which will apply to all AJAX requests (correct me if I'm wrong). </p>
  
  <p>I want to do something like this:</p>
  
  <pre><code>$.ajaxSetup({
    "error":function() {   
      $(this).ajax;
  }});
  </code></pre>
  
  <p>Would this work? Or even better: would this be the right way to do it? I would wrap the retry in a count system so that it doesn't infinitely retry. In my application 9 times out of 10 it will work correctly but every now and then one of the APIs I'm interfacing with will return an error.</p>
  
  <p>Any suggestions would help, thanks!</p>