title: auto refresh div containing javascript
body: <p>I want to refresh a DIV that has a JavaScript inside it every 5 seconds. I tried this code, but it only refreshes one time. how can I make it execute the JavaScript code every five seconds ?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/
  libs/jquery/1.3.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  var auto_refresh = setInterval(
  function ()
  {
  $('#content').load('count.html');
  }, 5000); // refresh every 5000 milliseconds
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div id="content"&gt;
      &lt;script type="text/javascript"&gt;
  
      today = new Date();
      BigDay = new Date("December 25, 2020");
      msPerDay = 24 * 60 * 60 * 1000 ;
      timeLeft = (BigDay.getTime() - today.getTime());
      e_daysLeft = timeLeft / msPerDay;
      daysLeft = Math.floor(e_daysLeft);
      e_hrsLeft = (e_daysLeft - daysLeft)*24;
      hrsLeft = Math.floor(e_hrsLeft);
      minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
      document.write("There are only&lt;BR&gt; &lt;H4&gt;" + daysLeft + " days " + hrsLeft +" hours and " + minsLeft + " minutes left &lt;/H4&gt; Until December 25th 2020&lt;P&gt;");
      &lt;/script&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>