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 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调