2010-07-08 85 views

回答

0

如果你真的需要它是准确的,你需要绘制它的客户端,最有可能的。您的PHP脚本可以返回描述进度条位置的JSON对象,然后您的脚本将绘制它。下面是从SO另一个问题是列出了一些JavaScript的图形选项:Which JavaScript graphics library has the best performance?

0

PHP

$purchased_num = 13; // items purchased until now (example) 

$max_width = 400; // the width of the bar 
$max_pur = 50; // the maximum number of items 
$one_pur_width = round($max_width/$max_pur); 

$width = $one_pur_width * $purchased_num; 

// print the div with this width 
// and style the bar with css 
// ... 

1

你应该使用jQuery经常重新加载小部分。

<div id="progBar"> 
</div> 

<script type=text/javascript> 
function refreshProgress() { 
    $.get('/folder/progbar.php', function (data) { 
     $('#progBar').html(data); 
    } 
    setTimeout('refreshProgress();',10000); 
} 

$(function() { refreshProgress(); }); 
</script> 

当加载页面时会加载progbar.php(这将基于在销售时的当前进度条)入格,并刷新每10秒。