2010-12-06 49 views

回答

2

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); 
2

您将需要使用AJAX与PHP文件进行交谈,该文件可以回显会话var。然后它可以更新进度条。

+0

我怎么能这样做?我对客户端开发不熟悉! – 2010-12-06 13:02:30

+0

使用jQuery的.ajax()方法。 – DampeS8N 2010-12-06 13:04:04