progress bar while waiting for server

前端 未结 4 756
被撕碎了的回忆
被撕碎了的回忆 2021-01-25 14:52

Some operations are time costly and it takes long time while waiting them to finish. Sometimes timeout occurs. I want to use a real time progress bar, so I want to show the sta

4条回答
  •  无人及你
    2021-01-25 15:18

    The easiest thing I can think of would be to implement a progress variable linked to the session (or a unique id) which is updated every so often by the slow-loading script. You can then have a 2nd page which returns the current contents of this variable. Query the status variable via ajax every few seconds to update your progress bar.

    Alternatively, you can use this method without ajax. Basically you flush a script that displays a progress bar to the browser from the slow page. As the page continues loading, it flushes javascript update() calls every so often to update the bar.
    http://devirtu.com/2008/10/16/making-progress-bar-of-page-loading/

提交回复
热议问题