progress bar while waiting for server

2019-02-28 15:51发布

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 status to the user and also I want to prevent timeout. Which technologies must I use? JS, Ajax, multithread or both? and how can I iplement this? Please advice.

4条回答
We Are One
2楼-- · 2019-02-28 16:01

If you are using an javascript and ajax, you can call / initiate the process(in server) from java script using an ajax call.You can show the user a loading image till you get a response back from the server. www.ajaxload.info allows you to generate your own loading images. have a look @ it. if you use jquery ,things would be much easier.

Check these links

http://docs.jquery.com/Ajax/load

http://www.shawngo.com/gafyd/index.html

Cheers

查看更多
Evening l夕情丶
4楼-- · 2019-02-28 16:13

I'd recommend using a library like jquery.

Here are some links:

Enjoy.

查看更多
来,给爷笑一个
5楼-- · 2019-02-28 16:23

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/

查看更多
登录 后发表回答