title: repeated AJAX call with http code return
body: <p>When a button is clicked I have a jquery AJAX call such as:</p>
  
  <pre><code>$(".play").click(function(){
      function doAjax(){
          $.ajax({
          url: 'blah.php',
          success: function(data) {
              if (data==250)
              {
                  setTimeout(doAjax, 2000);
              }
              else
              {
                  $('#quote p').html(data);
              }
  
          }
          });
      }
      doAjax();
  });
  </code></pre>
  
  <p>Any data from the server is printed to the div:</p>
  
  <pre><code>&lt;div id="quote"&gt;&lt;p&gt; &lt;/p&gt;&lt;/div&gt;
  </code></pre>
  
  <p>blah.php on the server does some processing to retrieve some status codes:</p>
  
  <pre><code>$r = new HttpRequest('http://localhost...', HttpRequest::METH_GET);
  $r-&gt;send();
  
  if ($r-&gt;getResponseCode() == 200)
  {
  echo "Starting video..."        
  //sends a video to play
  }
  else if ($r-&gt;getResponseCode() == 450)
  {
      echo "Oops! Not found...";
  }
  else if ($r-&gt;getResponseCode() == 550)
  {
      echo "Oops! An error occurred...";
  }
  else if ($r-&gt;getResponseCode() == 250)
  {
      echo "Initializing...";
  }
  else
  {
      echo "Now we are in trouble";
  }
  </code></pre>
  
  <p>The response codes (<code>$r-&gt;getResponseCode()</code>) get returned as I expect, so my problem is with my repeated ajax call with <code>setTimeout</code>. What I want to happen is that when code 250 is returned it prints out <code>Initializing</code>, which it does, but then my AJAX call will repeat because the success function is called with 250.  This doesn't work. It says <code>Initializing</code> but never repeats, because the next step is that I should see <code>Starting video...</code>.</p>
  
  <p>Everything else seems to check out, I guess the problem is with my jquery <code>success</code> function?</p>