我快疯了,我在 cakephp 表中有这段代码:
<td style="width:50%">
<div id="progress<?=$turnTime['TurnTime']['name'];?>">
<?php if ($turnTime['TurnTime']['end_time'] < date('Y-m-d H:i:s')) {
echo __('Waiting...');
}else{
$percent = ((strtotime($turnTime['TurnTime']['end_time']) - strtotime(date('Y-m-d H:i:s')))/
(strtotime($turnTime['TurnTime']['end_time']) - strtotime($turnTime['TurnTime']['start_time'])))*100;
$p = 'width: '.round($percent, 2).'%';
//show the time left
$current_date = new DateTime(date('Y-m-d H:i:s'));
$since_current = $current_date->diff(new DateTime($turnTime['TurnTime']['end_time']));
echo $since_current->h.' hours - '.$since_current->i.' minutes - '.$since_current->s.' seconds Left';
?>
<div class="progress progress-striped active" id="bar">
<div class="bar" style= "<?php echo $p; ?>"></div>
</div>
<?php } ?>
</div>
</td>
我想每秒自动刷新 div 数据
<div id="progress<?=$turnTime['TurnTime']['name'];?>">
我尝试了几种方法,但是....请帮助我,谢谢
我尝试像这样使用 jQuery:
<script>
$(document).ready(function(){
setInterval(showText(), 1000);
function showText(){
//alert("11");
$("#progress<?=$turnTime['TurnTime']['name'];?>").html(....some codes here...);
}
});
</script>
但它不起作用......