PHP刷新只是页面的一部分 [英] php refresh just a part of the page

查看:130
本文介绍了PHP刷新只是页面的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

helllo,所以我用php建立了一个倒计时

helllo so i builded a countdown with php

然后我注意到我必须刷新才能继续正确显示它.

then i noticed that i have to refresh to keep displaying it correctly.

因此我正在使用: header("refresh:1; url = time.php"); 在我的php中,但是它刷新了所有页面!

so im using: header( "refresh:1;url=time.php" ); inside my php ,but it refresh all the page!

是否可以像将其放置在div中一样,仅刷新页面的那部分..?这是im显示它的方式:

is there away to put it like in a div and only refresh that part of the page..?here is how im displaying it :

echo "Result: {$days}d {$hours}h {$minutes}m {$seconds}s<br/>\n"; 
echo "received: 7d 0h 0m 0s<br/>\n"; 
header( "refresh:1;url=time.php" );

推荐答案

尝试一下

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {
    $('#Status').load('record.php');
    }, 1000); // refresh every 1000 milliseconds
</script>
<body>
<div id="Status"></div>
</body>

制作一个新的php文件record.php并将您的倒计时代码放入其中,它将每秒刷新一次div

make new php file record.php and put your countdown code in it, it will refresh div every second

这篇关于PHP刷新只是页面的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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