开发者

Combine results of multiple ajax-requests

in my webapp there are two types of entities, which are in relation to each other. At first i grab some entities of type a and then for every single one of them, i grab the related one开发者_高级运维s of type b as an array. All working.

When all requests are done, i need an array of all returned type-b-arrays. Not working!

Whats the best way to accomplish that in jquery ?


As some others have commented here will need some code samples to get a bit more specific but a thought off the top of my head:

You could construct a global array of arrays that you feed you "type b" arrays into as they are returned from the ajax call. Would look something like this:

//Define this outside your function scope
var typeBArrays = new Array();

function someAjaxCallback(typeBArray){
    typeBArrays[typeBArrays.length] = typeBArray;
}

So when your processing is done you can access the typeBArrays array and have all your returned arrays.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜