Reputation: 1272
$.ajax({
url: '/api/1.0/tweets.php?username=' + username
}).done(function (data) {
//For loop here to do something multiple times
)};
I have this piece of code. I'm trying to get something on my web page to display one at a time, but I believe the problem with my code is that done()
is causing nothing to return until the entire for loop is finished.
Maybe there's another function other than done()
?
Upvotes: 0
Views: 202
Reputation: 2502
Welcome to the world of asynchronous Javascript! One piece of advice: instead of thinking in terms of data being returned from functions, think in terms of functions that are executed each time some piece of data is ready.
What you need is something that will call your callback each time a piece of data is available. A similar question was asked here, with several answers that you may find helpful.
Upvotes: 4