What is the best way to work with Ajax requests without sequence (preferably using jQuery)?
For example, an Ajax request is sent from the user's browser at any time when the field changes. The user can change dog_nameto Fluffy, but after a moment she will change it to Spot. The first request is delayed for some reason, so it arrives at the server after the second, and its dog ends up with what is called "Fluffy" and not "Spot".
I could skip the time stamp on the client side with each request and transfer the server as part of each record Dogand ignore previous requests to change the same field (but only if there is a difference of less than 5 minutes if the user changes the time on his computer) .
Is this approach reliable enough or is there a more standardized approach?
EDIT:
Matt made a wonderful point in his comment. It is much better to serialize requests to change the same field, so is there a standard way to implement Ajax request queues?
EDIT No. 2
In response to a comment by @cherouvim, I don't think I will have to block the form. The field is modified to reflect the user's change, the change request is queued. If a request to change the same field is waiting in a queue, delete this old request. 2 things that I would still need to address:
Queuing a request is an asynchronous task. I could have a callback handler from a previous Ajax request to send the next request to the queue. Javascript code is not multithreaded (or ... is this?)
If the request fails, I will need a user interface to reflect the status of the last successful request. Thus, if the user changes the dog’s name to “Spot” and the Ajax request fails, the field should be returned in “Fluffy” (the last value completed successfully).
?