zoukankan      html  css  js  c++  java
  • php+ajax+jquery 定时刷新页面数据

    testajax.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />

    <title>testajax</title>

    </head>

    <body>

    <script src='http://www.kuitao8.com/images/js/jquery-1.9.1.min.js'></script>

        <script type= "text/javascript">

    $(document).ready(function() {

        function update() {

          $.ajax({

           type: 'GET',

           url: 'ajax.php',

           success: function(data) {

              $("#timer").html(data);

              //window.setTimeout(update, 1000);

           },

          });

         }

        setInterval(function(){update();}, 1000);

         //update();

    });

    </script>

    <div style="margin:80px auto;500px;font-size:32px;color:red;">

    <div id="timer"> </div>

    </div>

    </body>

    </html>

    ajax.php

    <?php

        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');

        header('Cache-Control: no-cache, must-revalidate');

       

        include_once 'inc/conn.php';

        include_once 'inc/utility2.php';

        include_once 'inc/utility_all.php';

        include_once 'inc/utility.php';

       

        global $connection;

       

        $stunum="4257330415748211";

        $snum='3';

        $sql = "select * from jo_reviewmsg where pnum='{$stunum}'  and snum='{$snum}' and status='2' order by id desc limit 1";

        $result=mysql_query($sql,$connection);

        if($row=mysql_fetch_array($result)){

            $flag=$row['flag'];

            $reason=$row['reason'];

            $retstr=$flag.$reason;

        }

        else

            $retstr='';

     

        date_default_timezone_set("Asia/Shanghai");

        echo date("Y-m-d H:i:s")." ret=".$retstr;

    ?>

  • 相关阅读:
    CF351A Jeff and Rounding 思维
    CF352B Jeff and Periods 模拟
    CF352A Jeff and Digits
    小B的询问 莫队分块
    小凯的疑惑 数学
    BestCoder Round #80 待填坑
    [SDOI2009]HH的项链 树状数组 BZOJ 1878
    Blocks poj 区间dp
    [USACO5.4]奶牛的电信Telecowmunication 最小割
    数位dp
  • 原文地址:https://www.cnblogs.com/xihong2014/p/6039584.html
Copyright © 2011-2022 走看看