var test = function () {
if (condition) {
console.log('ok')
}
else {
setTimeout(test, 1000);
}
}
test();
Request do serwera co 1 minutę:
var timer = window.setInterval(function () {
var time = (new Date).getTime();
var ajax = jQuery.ajax({
url: '?a=touch',
cache: false,
type: 'get',
dataType: "json",
data: {
time: time
},
success: function (data) {
}
})
}, 60000);