I am aware that when coding an extension, there is no way we can delay a function call except for using a setTimeout call but here's what I am trying to achieve in a plugin that I am developing for firefox (this is not for javascript embedded into a webpage by the way):
for (var i = 0; i < t.length ; i++) {
//Load a URL from an array //On document complete, get some data
}
The idea is simple. I have an array of URLs that I want to parse and extract some data out of. Each of these URLs take some time to load. So, if I try to get some data from the current page without waiting for the page to load, I will get an error. Now, the only way to do this as I know is as follows:
firstfunction: function() {
//Load the first url setTimeout("secondfunction", 5000);
}
secondfunction: function() {
//Load the second url setTimeout("thirdfunction", 5000);
}
And so on... I know this is obviously wrong.. I was just wondering how people achieve this in javascript...
EDIT: Sorry about not being more detailed...