Ignoring old multiple asynchronous ajax requests

Posted by Travis on Stack Overflow See other posts from Stack Overflow or by Travis
Published on 2010-03-17T20:20:28Z Indexed on 2010/03/17 20:21 UTC
Read the original article Hit count: 523

Filed under:
|
|

I've got a custom javascript autocomplete script that hits the server with multiple asynchronous ajax requests. (Everytime a key gets pressed.)

I've noticed that sometimes an earlier ajax request will be returned after a later requests, which messes things up.

The way I handle this now is I have a counter that increments for each ajax request. Requests that come back with a lower count get ignored.

I'm wondering: Is this proper? Or is there a better way of dealing with this issue?

Thanks in advance,

Travis

© Stack Overflow or respective owner

Related posts about asynchronous

Related posts about AJAX