help understanding the concept of javascript callbacks with node.js, especially in loops
Posted
by
Mr JSON
on Stack Overflow
See other posts from Stack Overflow
or by Mr JSON
Published on 2010-12-22T04:49:00Z
Indexed on
2010/12/22
4:54 UTC
Read the original article
Hit count: 271
hi I am just starting with node.js. I have done a little ajax stuff but nothing too complicated so callbacks are still kind of over my head. I looked at async but all I need is to run a few functions sequentially. I basically have something that pulls some json from an api, creates a new one and then does something with that. obviously i can't just run it because it runs everything at once and has an empty json. mostly they have to go sequentially but if while pulling a json from the api it can pull other json while it's waiting that is fine. I just got confused when putting the callback in a loop. what do I do with the index? i think i have seen some places that use callback inside the loop as kind of a recusive function and don't use for loops at all.
simple examples would help alot thanks!
© Stack Overflow or respective owner