JavaScript Function Queue

前端 未结 6 2136
小蘑菇
小蘑菇 2021-01-18 16:40

I have a ton of functions that need to run in succession, but not before the other has completed. What I need is a way to queue these functions to run only after the previou

6条回答
  •  猫巷女王i
    2021-01-18 17:08

    Why don't you do exactly as you have shown, by listing them in a covering function?

    function do_1_to_5() {
        Function1(); 
        Function2(); 
        Function3(); 
        Function4(); 
        Function5();
    }
    

    If your function contains AJAX calls, then you need to hook them up at the end of the callback functions that handle the AJAX calls.

提交回复
热议问题