How to execute a Javascript function only after multiple other functions have completed?

后端 未结 7 2058
轻奢々
轻奢々 2020-12-25 15:03

My specific problem is that I need to execute a (potentially) large number of Javascript functions to prepare something like a batch file (each function call adds some infor

7条回答
  •  误落风尘
    2020-12-25 15:54

    Have a look into jQuery's deferred objects. This provides a sophisticated means of controlling what happens when in an asynchronous environment.

    The obvious use-case for this is AJAX, but it is not restricted to this.

    Resources:

    • jQuery docs: deferred object
    • good introduction to deferred object patterns
    • Non-AJAX use for jQuery's deferred objects

提交回复
热议问题