【发布时间】:2012-02-17 20:19:56
【问题描述】:
我想处理一些在 iframe 中呈现的实时更新。这个名为 disp.php 的文件在数据库中查询一个表“posts”并从下到上显示它们。现在,当新条目添加到“帖子”时,我希望它能够实时反映。
我可以使用
<meta http-equiv="refresh" content="10" />
在 disp.php 中。但是持续的清爽感觉还是很烦人。现在我正在尝试以这种方式实现刷新,这是行不通的。
<!DOCTYPE html>
<html>
<head>
<title>Live Updates</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js">
</script>
<script>
function refreshLiveFrame() {
$('body', window.frames['myliveframe'].document).loadIfModified("disp.php");
setTimeout("refreshLiveFrame()", 1000);
}
$(document).ready(function() {
refreshConsole();
});
</script>
</head>
<body>
<iframe name="myliveframe" src="disp.php">
</iframe>
</body>
</html>
我需要一种实时异步刷新的方法。有人有解决方法吗?谢谢。
【问题讨论】:
标签: jquery iframe refresh updates