I developed a PHP countdown timer (3hrs specifically in hrs, mins and secs) – countdown.php. The output is within a <div> tag in another page – index.html.
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.
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.
countdown.php
<?php
//some codes left out
$remainingHour=floor($secsdiff/3600);
$remainingMinute=floor(($secsdiff-($remainingHour*60*60))/60);
$remainingSecond=floor(($secsdiff-($remainingHour*60*60))-($remainingMinute*60));
?>
index.html
<div id="timer">
<?php echo "$remainingHour hours, $remainingMinute minutes,
$remainingSecond seconds";?>
</div>
Make sure your using JQuery in your HTML page (Follow the tutes on the JQ website if this is new to you, It’s really very easy)
Then once your up and running with that, use JQuerys Get function to update your div:
http://api.jquery.com/jQuery.get/
You should be able to get it up and working in 30 mins or less, it’s very simple.