Ok so I have a button 'up' which when pressed starts a countdown from 8 and when it reaches 0 an ajax call to update.php is made which in turn updates an sql table. update.php is working.
<input type='button' id='countdw' value='Wait 8s' class='btn btn-primary disabled'>
This is working, just not each time the countdown reaches 0. This bit of code doesn't seem to execute each time
$.ajax({
url: "update.php",
Here is the code
<script>
var secsLeft = 8;
setInterval(function(){
secsLeft--;
if(secsLeft > 0){
$('#countdw').val('Wait ' + secsLeft + 's');
} else if(secsLeft == 0){
$('#countdw').removeClass('disabled');
$('#countdw').val('UP');
$('#countdw').attr("onclick","myfunction()");
}
}, 1000);
</script>
<script>
count=0;
function myfunction(){
if(mycount!=0 && mycount%25==0){
}else{
var secsLeft = 8;
setInterval(function(){
secsLeft--;
if(secsLeft > 0){
$('#countdw').addClass('disabled');
$('#countdw').val('Wait ' + secsLeft + 's');
} else if(secsLeft == 0){
$('#countdw').removeClass('disabled');
$('#countdw').val('UP');
$('#countdw').attr("onclick","myfunction()");
$.ajax({
url: "update.php",
data:{'user':'<?php echo $subid ?>','data':'<?php echo $key ?>'},
success: function(result){
}
});
}
}, 1000);
}
up();
}
</script>
Any help would be greatly appreciated.