(function poll() { $.ajax({ url: '/api/', type: 'GET', dataType: 'json', success: function() { console.log('success'); }, timeout: 3000, complete: setTimeout(function() { poll(); }, 6000) })})();