Using async.parallel along with Javascript

▼魔方 西西 提交于 2019-12-24 10:19: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?

来源:https://stackoverflow.com/questions/8810825/using-async-parallel-along-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!