After spending the last 45 minutes looking around for a solution, I can't seem to find an easy solution to creating a countdown timer using PHP and jQuery. Most already built scripts I've found are based purely on jQuery which require a ton of code, and more parameters then they should, plus, adaptability is pretty hard.
Here's my situation;
PHP:
$countdown = date(h:i:s); // This isn't my actual $countdown variable, just a placeholder
jQuery:
$(document).ready(function name() {
$(#this).load( function() {
setTimeout(name(), 1000)
}
}
});
HTML:
<div id=this><?php echo($countdown); ?></div>
My idea is that, every second, #this
is reloaded, giving a new value to it's contents, and as $countdown isn't a static variable, a new value will be loaded each time. This removes the need to deal with sessions (as a basic javascript countdown timer would reset on pageload, etc).
I would've though this would have worked, until I realized that the event binder .load()
doesn't reload #this
(I know silly me), so I guess what I'm wondering is - is there an event binder I can use to make this work or is there a way to get the functionality I'm looking for, without using a jQuery plugin (which doesn't match exactly what I want anyway)?