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
successwill be executed very often.So I recommend you to use setTimeout or setInterval instead!