> From: MrNase > > I have the function called init() where I use Ajax.get to > fetch the list and I have several other functions but writing > them down like: > > $(document).ready(function() { > init(); > otherfunction(); // booth need the data provided by init(); > function(); > }); > > doesn't work. otherfunction() and function() are unable to > work with the data generated by init()
The Ajax download is asynchronous. When your init() function returns, the data hasn't been downloaded yet. Use the callback parameter to $.get to provide a function which will be called when the download is complete. Call your otherfunction() and function() from within that callback function. http://docs.jquery.com/Ajax#.24.get.28_url.2C_params.2C_callback_.29 -Mike