如何根据PHP会话变量中的值更新jQuery进度栏 [英] How to update jQuery Progress bar according to a value at the session variable in PHP

查看:69
本文介绍了如何根据PHP会话变量中的值更新jQuery进度栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据会话变量的当前值填充进度栏.该值将不是恒定的并且正在增加. 如何使其自身加载?

I need to fill the progress bar according to the current value of a session variable. The value will be not be constant and is increasing. How to make it load by itself?

<meta charset="utf-8">
    <script>
    $(function() {
        $( "#progressbar" ).progressbar({
            value: 80
        });
    });
    </script>
 <div class="demo">

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

</div>

推荐答案

PHP

...
// disable caching
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Expires: Mon, 26 Jul 1991 05:00:00 GMT');  // disable IE caching
header('Content-Type: text/plain; charset=utf-8');

echo progressbar_value;
exit();
...

JS

var refresh_period = 1000; // ms
var script_path = '/script.php';

function updateProgressBar () {
    $.ajax({url: script_path,  success: function (value) {
       $('#progressbar').progressbar(value);
       if (data.value == 100) {
          clearInterval(interval);
       }
    }
}
var interval = setInterval('updateProgressBar()', refresh_period);

这篇关于如何根据PHP会话变量中的值更新jQuery进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆