Using setInterval to fetch user data from Ajax is bad practice. We cannot assume one request will be finished before next request is called. The problem will likely appear when user have a bad internet connection or server in a high load.
The solution is waiting for the Ajax request to complete and then call the next one. We can use Promise to help us implement this.
Using
setInterval
to fetch user data from Ajax is bad practice. We cannot assume one request will be finished before next request is called. The problem will likely appear when user have a bad internet connection or server in a high load.The solution is waiting for the Ajax request to complete and then call the next one. We can use
Promise
to help us implement this.