【发布时间】:2015-10-31 07:53:27
【问题描述】:
我正在尝试创建一个类似但用于显示数据库内容的 FB 新闻提要。 我的代码已经读取了表格的行数,但它需要在更新 html 的内容之前刷新页面。
这是我的代码:
我的 html 文件的一部分:
<section id="reportcontent"></section>
<script>
(function refreshNews()
{
$("#reportcontent").load("php/ajax.php");
})();
setInterval('refreshNews()',1000);
</script>
ajax.php 的内容
<?php
require("database.php");
$sql = "SELECT * FROM report";
$res = odbc_exec($conn,$sql);
while($feedItem = odbc_fetch_array($res))
{
echo "hello! <br>";
}
?>
如您所见,我的表格的每一行都会回显一个 hello 文本。但为了查看新的行数,我需要刷新页面。感谢您的帮助!
【问题讨论】:
标签: javascript php jquery html ajax