Вы можете сделать:
(function poll() {
$.ajax({
...
success:function(response) {
if (!condition_is_met) {
poll();
}
}
});
})(); //This calls the poll function inmediatly
Если вы хотите, чтобы вас казнили точно по истечении определенного времени, вы можете сделать:
setInterval(function poll() {
if(condition_is_met){
$.ajax({
...
success:function(response) {
//your code here
}
});
}
}, 5000); //Execute every 5 seconds
Надеюсь, это поможет. Приветствия