(function refreshPendingIncidents() { $.ajax({ url: '/pending-incidents/refresh/' + "{{ $reports[0]->id }}", success: function(data) { console.log(data) console.log('test') }, complete: function() { // Schedule the next request when the current one's complete setTimeout(refreshPendingIncidents, 3000); } }); })();