I want to work on some Live Updates which is rendered in an iframe. This file called disp.php queries a table “posts” in the database and displays them all from bottom to top. Now when a new entry is added to “posts”, I want it to be reflected real-time.
I could achieve it using
<meta http-equiv="refresh" content="10" />
in the disp.php. But still the constant feel of refreshing is annoying. Now I’m trying to achieve the refresh this way, which doesn’t work.
<!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>
I need a way for a live asynchronous refresh. Anybody’s got a workaround? Thanks.
1 Answer