javascript - 在特定时间间隔内刷新 PHP 所需的文件

标签 javascript php html reload ajax-polling

我试过这些:

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

最佳答案

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 次加载页面。

关于javascript - 在特定时间间隔内刷新 PHP 所需的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46277499/

相关文章:

javascript - 为什么带有选项的 Intl.NumberFormat 在左侧输出欧元符号,而文档说它应该在右侧?

javascript - 自动提交并刷新一次

javascript - 无法解析 JSON (xmlhttp)

php - 如何强制执行 protected 静态函数

javascript - 如何在选择 TR 时向 TR 中的每个 TD 添加类

html - 中心标签适用于链接,但不适用于 CSS 或对齐属性

javascript - 这两个循环表达式的语法是什么意思?

javascript - 带有 Angular $resources 的 query() 始终为 “Undefined is not a function”

即使我安装了 PHP7 并将其添加为解释器,PhpStorm 项目仍在使用 PHP5

html - 图像 Sprite 尺寸大于容器,如何将其放入较小的容器中