I was making a button that submits an AJAX request to update shopping cart when clicked.
The problem is, if the user clicks a multiple times in quick succession, the script won’t be able to update it (eg. clicked 10 times in 2 seconds, only added the item twice).
I wonder if there is anyway to queue up the ajax requests?
You can implement a simple queue the following way:
This guarantees you to execute the requests in order and one after another after each request has been completed.