I am creating a countdown of '90s` using jquery.
But the countdown is repeating.
I tried:
<script>
var checkStatet = function(){
jQuery.ajax({
url: 'check_diffex.php?od=deotd'
}).done(function(data){
var o = data.diffex;
var time = jQuery('#rbtntime');
var timer = setInterval(function() {
time.html(o);
if (o == 0) {
$('#rbtntimep').hide();
clearInterval(timer);
}
o--;
}, 1000)
});
}
checkStatet();
setInterval(checkStatet, 1000);
</script>
<p>You need to wait <span id="rbtntime">90</span> before you can proceed</p>
check_diffex.php:
<?php
header('Content-Type: application/json');
$e = "90";
// You would calculate a real value here
echo json_encode([
'diffex' => $e
]);
?>
I am creating a countdown of '90s` using jquery.
But the countdown is repeating.