Sequencing ajax requests

Posted by Scott Evernden on Stack Overflow See other posts from Stack Overflow or by Scott Evernden
Published on 2010-06-14T03:51:12Z Indexed on 2010/06/14 4:02 UTC
Read the original article Hit count: 163

I find I sometimes need to iterate some collection and make an ajax call for each element. I want each call to return before moving to the next element so that I don't blast the server with requests - which often leads to other issues. And I don't want to set async to false and freeze the browser.

Usually this involves setting up some kind of iterator context that i step thru upon each success callback. I think there must be a cleaner simpler way?

Does anyone have a clever design pattern for how to neatly work thru a collection making ajax calls for each item?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery