简体   繁体   English

是否有可能使实时进度/百分比栏在jQuery中

[英]is it possible to make real time progress/percentage bar in jquery

Below code is simple jquery progress bar. 下面的代码是简单的jquery进度栏。 Is there any way to update progress value (that is 67 rite now)dynamically on ajaxStart and reach this value to 100 on ajaxStop()? 有什么方法可以在ajaxStart上动态更新进度值(现在是67个礼拜),并在ajaxStop()上达到100。

<head><script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />



    <script>
        $(function() {
            $( "#progressbar" ).progressbar({
                **value: 67**
            });
        });
    </script>
</head>


 <body>
    <div id="progressbar"></div>
</body>

If you are targetting HTML5 browsers only, then try whats decribed here: Jquery Ajax Progress in HTML5 如果仅将HTML5浏览器作为目标,请尝试此处介绍的内容: Jquery Ajax HTML5中的进度

The traditional way to go about this would be to show a spinning gif, instead of the loader. 解决此问题的传统方法是显示旋转的gif,而不是加载程序。

Ajax request wont be too long in most of the cases & hence all the effort in trying for the same is lost. 在大多数情况下,Ajax请求不会太长,因此,尝试相同的所有工作都将丢失。

However it is not uncommon for a progress bar to be shown. 但是,显示进度条并不少见。 The problem is, older browsers did not share this info with JS & the developers were left to using hacks like, 问题是,较旧的浏览器未与JS共享此信息,而开发人员只能使用诸如

  • Using the help of flash. 使用闪光灯的帮助。 Flash plugin could keep track of the amount of data uploaded & hence tell the javascript. Flash插件可以跟踪上传的数据量,从而告诉javascript。

  • A method of approximating the time also works in certain cases. 在某些情况下,也可以使用一种近似时间的方法。

  • The only choice that remains is to ping the server continuously to know how much transfer took place. 剩下的唯一选择是连续ping服务器以了解发生了多少传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM