dongtangze6393 2015-07-13 18:42
浏览 37
已采纳

php只刷新页面的一部分

helllo so i builded a countdown with php

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

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

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/>
"; 
echo "received: 7d 0h 0m 0s<br/>
"; 
header( "refresh:1;url=time.php" );
  • 写回答

1条回答 默认 最新

  • doukuizuo1795 2015-07-13 19:12
    关注

    try this

    <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>
    

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)