不断刷新/接收输出<div>

时间:2016-10-17 03:29:51

标签: javascript php jquery html css

所以我在我的网站上有这个div

<div class="col-sm-4"  >
  <div id="RealTimeClose" class="nest">
    <div class="title-alt">
      <h6>
        <span class="fontawesome-resize-horizontal"></span>&nbsp;Deposit Feed</h6>
      <div class="titleClose">
        <a class="gone" href="#RealTimeClose">
          <span class="entypo-cancel"></span>
        </a>
      </div>
      <div class="titleToggle">
        <a class="nav-toggle-alt" href="#RealTime">
          <span class="entypo-up-open"></span>
        </a>
      </div>
    </div>
    <div id="RealTime" style="min-height:296px;padding-top:20px;" class="body-nest">
      <?php include('table1.php'); ?>
    </div>
  </div>

我试图让它在1秒间隔后继续从table1.php加载数据......我怎么能这样做

2 个答案:

答案 0 :(得分:1)

$(function() {
    function reloadTable(){
        $.get( "table1.php", function( data ) {
            $( "#RealTime" ).html( data );
        });
    }
reload = setInterval(reloadTable, 1000);
});

答案 1 :(得分:0)

Uing JQuery / AJAX将解决您的问题。

<html>
    <head>
        <title>New document</title>
        <script src="jquery.js"></script> <!-- This is for including the JQuery, found at https://jquery.com -->
    </head>
    <body>
        <script>
            $(document).ready(function(){
                $.ajaxSetup({cache:false});
            });
            var Interval = setInterval(function(){
                $("#users").load("table1.php"); // $("#users") is a selector to select the id "users", and the load function explains itself...
            }, 1000/*Refresh rate : currently one second*/);
        </script>
        <p>Users found: </p>
        <div id="users">Users found her</div>
    </body>
</html>