title: Sinatra app bombards server with requests
body: <p>I'm trying to write a small sinatra application following along the lines of the <a href="http://screencasts.org/episodes/ajax-website-with-sinatra-jquery" rel="nofollow">screencast.org</a> screencast. I want to use jQuery for ajax along with sinatra.</p>
  
  <p>As soon as I start, my app floods the server with requests. Firebug shows that the requests mount upto 2MB/second.</p>
  
  <p>These are the contents of my <code>layout.erb</code>.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Is it My Birthday&lt;/title&gt;
  
  &lt;script src="jquery.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function getUpdate()
  {
    setTimeout(getUpdate, 1000);
    $("body").load("/");
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;%= yield %&gt;
  
  
  &lt;script&gt;
  $(getUpdate);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Instead of running once each second, it runs infinitely. Where have I gone wrong?</p>