Welcome Guest, Not a member yet? Register   Sign In
What's the standard way of dealing with the ordering of multiple ajax requests?
#1

I've never had to code up some functionality that created a situation where there were multiple ajax requests that need to have responses in order that they were requested. In this particular case, it would be acceptable an out of order response was dropped. I for sure want to retain async behavior, and was wondering if the following idea is good, or if there is a better way:

1) Do ajax request. (using jQuery) Ajax request is assigned a number, and number is posted in request, and responses have the same number.
2) If a response comes back and the number is greater than the last known number to come back, it's considered to take action. If the number is not greater than the last known number to come back, nothing happens.

This kind of behavior is something that could be used with a (keyup|change|blur) type event. Fetching of common search terms, password strength values, etc.

Seems like a simple concept, but is there something better? Is there something else that I need to be thinking about?
Reply


Messages In This Thread
What's the standard way of dealing with the ordering of multiple ajax requests? - by skunkbad - 05-03-2017, 10:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB