I am working with a setInterval function that executes asynchronous code to make calls to the server:
setInterval(()=> {
//run AJAX function here
}, 5000);
In scenarios where the server does not receive a response within 5 seconds, there is a likelihood that setInterval will run again and initiate multiple requests on the same endpoint. Is there a way to ensure that the next execution of setInterval only starts after the AJAX function successfully returns a response?