-1
Good I have the following Javascript code
function fun() {
$.ajax({
url: 'aposta.php',
success: function(a){
if(a) {
a = JSON.parse(a);
$("#tempo").html(a.time);
if (a.time === 0) {
$('#oi').attr('disabled', 'disabled');
setTimeout(function() {
$('#oi').removeAttr('disabled');
}, 6000);
}
$("#box").animate({
'background-position-x': numero(a.numero)
}, 500);
}
else {
$("#tempo").html("0");
}
}
});
};
setInterval(function(){
fun();
}, 1000);
</script>
What I intended was that setinterval that updates 1 in 1 second put, an html code, so that this html code is updated without refresh in case I give some change in the site.
Basically, what I want is to update this variable $balance in php every 1 second without having to give F5 on the site.
How can I do that?
Thank you.
What does an error in ajax have to do with updating real number?
– Gonçalo
None of the questions are very clear, and the problems seem to be the same (I thought this, perhaps because they are not clear). If you edit both, making it more clear what you want, I withdraw the vote to close.
– user28595
I’ll edit, thanks for warning me diego.
– Gonçalo
I’ve already edited Diego
– Gonçalo