How to invoke a “Please Wait” window only if ajax takes more than X milliseconds to respond?

后端 未结 4 1094
心在旅途
心在旅途 2020-12-07 06:18

I\'m doing an AJAX call (regular JS) and, if it takes more than, say, 500 milliseconds, I\'d like to put up my \"Please Wait\" box.

Normally, if I want to put up the

4条回答
  •  情歌与酒
    2020-12-07 06:46

    It shouldn't come after the ajax call, it should come inside the callback function. AJAX requests are asynchronous with the rest of the code, you should preform actions you want upon completion inside the callback part of your request.

提交回复
热议问题