title: PHP timer output into HTML div every second
body: <p>I developed a PHP countdown timer (3hrs specifically in hrs, mins and secs) - countdown.php. The output is within a <code>&lt;div&gt;</code> tag in another page - index.html.</p>
  
  <p>I want an AJAX or Javascript that would make the output dynamic (that is changing figures like normal timer).  I do know that AJAX can make the page refresh every second in the background (asynchronously), but I've not been able to achieve that.</p>
  
  <p>Presently, the output only changes when I refresh the HTML page. I also want a PHP script to be triggered when countdown gets to zero.</p>
  
  <h3>countdown.php</h3>
  
  <pre><code>&lt;?php
  //some codes left out    
   $remainingHour=floor($secsdiff/3600);
   $remainingMinute=floor(($secsdiff-($remainingHour*60*60))/60);
   $remainingSecond=floor(($secsdiff-($remainingHour*60*60))-($remainingMinute*60));
  ?&gt;
  </code></pre>
  
  <h3>index.html</h3>
  
  <pre><code>&lt;div id="timer"&gt;
  &lt;?php echo "$remainingHour hours, $remainingMinute minutes, 
  $remainingSecond seconds";?&gt;
  &lt;/div&gt;
  </code></pre>