If I want to implement short polling like this:
function firstCall(){
$.ajax({
...
success: function(response){
if (response.OK == "OK"){
secondCall();
}else{
firstCall();
}
}
});
}
Will this be enough? or do I really need to surround the firstCall() in else clause with setTimeout ?Thanks
I recommend you to use a little timeout, because now you are creating a lot of traffic to your server. Ajax is fast and success will be executed very often.
So I recommend you to use setTimeout or setInterval instead!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With