progress bar while waiting for server

前端 未结 4 757
被撕碎了的回忆
被撕碎了的回忆 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/

    0 讨论(0)
  • 2021-01-25 15:21

    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

    0 讨论(0)
  • 2021-01-25 15:27

    I'd recommend using a library like jquery.

    Here are some links:

    • jquery progress bar link 1
    • jquery progress bar link 2

    Enjoy.

    0 讨论(0)
  • 2021-01-25 15:44

    We have some similar questions. Please edit your question to tell us exactly what you need.

    How to implement a progress bar in Ruby?

    Creating a file progress bar in PHP

    Progress bar in HTML/CSS

    AJAX progress bar dispaying loading progress percentage for page load

    0 讨论(0)
提交回复
热议问题