Using the equivalent of $ .when (). Done () in jQuery 1.4

I need to make two different JSON requests and combine these requests into one function. I would like to use the following construction:

$.when( $.getJSON(url1), $.getJSON(url2) ).done(function(data1, data2) { someFunction(data1, data2); }); 

Unfortunately, for this project we are using jQuery 1.4 and $ .when was introduced with jQuery 1.5. Is there any equivalent for this in jQuery 1.4?

Thanks in advance!

+3
source share
1 answer

To implement this functionality, I made an array in which each element is a flag that says if this particular getJSON is complete. Also, with every successful function, I check the full array, which should be completed if not (good all the time). I am adding the resulting json (and some context) to another โ€œresult arrayโ€. But if everything is done, then I perform the last function against the "array of results"

+2
source share

All Articles