Last Updated: December 30, 2020
·
1.19K
· dizpers

Execute a bunch of asynchronous method with one callback

Solution

http://stackoverflow.com/a/2911891/764182

Background

This protip is related to my other protip - "Get random item with image encoded with base 64 (AJAX)". So my task was to include 3 randomly picked items (via ajax request) in page.

So, the final order of tasks was:

1) Load settings.json file

2) Load first item, add to items array

3) Load second item, add to items array

4) Load third item, add to items array

5) Render items array

So, (1) should be done before all tasks. [(2),(3),(4)] should be done before (5). [(2),(3),(4)] may be [(3),(4),(2)] or [(2),(4),(3)], etc...

2 Responses
Add your response

can you please add some background to this concept. Such as when and why someone would need to execute a bunch of async methods with one callback. I think that would be helpful.

over 1 year ago ·

@davidchase03 Thx for reply!:) I added a short background. Should it be more specific?

over 1 year ago ·