How do you make javascript code execute *in order*

后端 未结 9 1206
别那么骄傲
别那么骄傲 2020-11-30 05:49

Okay, so I appreciate that Javascript is not C# or PHP, but I keep coming back to an issue in Javascript - not with JS itself but my use of it.

I have a function:

9条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 06:26

    move the updateStatus calls to another function. make a call setTimeout with the new function as a target.

    if your ajax requests are asynchronous, you should have something to track which ones have completed. each callback method can set a "completed" flag somewhere for itself, and check to see if it's the last one to do so. if it is, then have it call hideLoader.

提交回复
热议问题