嗨,我使用了这个php代码:
<?php
if (isset ($_GET['update']))
{
echo $status;
die ();
}
?>
和这个javascript代码:
<script type="text/javascript">
$(document).ready (function ()
{
var updater = setTimeout (function ()
{
$('div#center2').load ('index.php', 'update=true');
}, 5000);
});
</script>
这确实刷新了我的注释所在的部分,但是它基本上删除了注释,并且没有发布任何注释,只显示一个空白......请帮帮我。
Make one action.php
file.
if (isset($_POST['action']) && $_POST['action'] == 'update_comments') {
// echo all updated comments you want
}
Then in, index.php page use jquery like this,
var updater = setTimeout (function () {
$.post("action.php", {action:'update_comments'}, function(data) {
$('div#center2').html(data);
}
}, 5000);
Here, in jquery second line, action.php
is url of action.php
file. This file can be used for many other functions like this, by simply adding more if loops and action name to it.