I have 2 variable and i want to do something when they changed to same value like each other. So this is my code:
var val_1,val_2;
for(i=0;i<=5;i++){
readyforgo++;
$.post("somewhere.php",{
something: something
},function(data, status){
readytogo++;
});
}
if(readyforgo==readytogo){
alert(1);
}
Its not gonna return 1 because my if is working faster than my $.post
i mean i want some code like this :
function checker(){
if(readyforgo==readytogo){
alert(1);
}else{
setTimeout(function(){checker();},100);
}
}
checker();
Its working as well but i looking for something better i mean i don't want to use any code like that because its using cpu and ram until trying to get readyforgo==readytogo
do we have code like this?
i don't like to use setTimeout or setInvertal or something like that.