Using async.parallel along with Javascript

2019-08-02 09:10发布

I posted a question some time about about working with async calls in JS. The answers there did not help me, but later on I found out about modules that would solve my problems, for example async.

The thing is, I don't know how to use these modules yet (I'm a noob at JS) and I was hoping that someone would be able to point me in the right direction here. Specifically, I'd like to know how to use the async.parallel.

The function that I'm trying to get executed in parallel is the success callback function of a jQuery get() call, as shown below:

$.get($(this).attr("href"), function(data) {
     temp = parse_page(data);
     var el = page_num.split(" ");
     pages[el[el.length-1]] = data;
});

The problem I'm having is that the number of these get() calls that I would need to do is variable.

How would I go about putting these variable number of function calls in an array and then use that array with async.parallel?

0条回答
登录 后发表回答