一个特定的时间间隔

问题描述:

内刷新一个PHP所需的文件我尝试这些:一个特定的时间间隔

<div id="result"> 
<table> 
<?php require('newses.php'); ?> 
</table> 
</div> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
    <script> 
function autoRefresh_div() 
{ 
     $("#result").load("load.html");// a function which will load data from other file after x seconds 
    } 

    setInterval('autoRefresh_div()', 1000); // refresh div after 5 secs 
      </script>  

但它没有为我工作。 请访问这些页面:

Reload the content of a div afer regular interval of time

http://devzone.co.in/automatically-refresh-html-page-div-specific-time-interval/

+1

刷新时间为1分钟而不是5秒钟。 – Sand

+1

检查控制台什么是错误。在我身边重新加载 – Abhishek

+0

@Sand如何设置1秒? – Jishnuraj

我找到了答案我自己。 我的代码中存在一个小问题。 我想让我的页面在我的页面中包含newses.php文件,并在每1秒后刷新一次相同的文件(newses.php)。 JavaScript代码有一个小问题。刷新页面的代码名称为load.html,以便浏览器在首次加载网页1秒后尝试加载load.html页面。 当我将的刷新代码更改为$("#result").load("newses.php");// a function which will load data from other file after x seconds时,我的页面完全正常工作。 这里是编辑的代码。 ()),1000(); //一个函数,它会在x秒后从其他文件载入数据} setInterval('autoRefresh_div()',1000 ); // 5秒后刷新div

function autoRefresh_div() { 
 
    $("#result").html('<object data="https://static.pexels.com/photos/17679/pexels-photo.jpg"/>'); // a function which will load data from other file after x seconds 
 
    alert('working'); 
 
} 
 

 
setInterval(autoRefresh_div, 5000); // refresh div after 5 sec
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="result"></div>

这将加载页面曾经5