Php 如何在页面外重新压缩的情况下加载其他评论

Php 如何在页面外重新压缩的情况下加载其他评论,php,ajax,Php,Ajax,自动加载其他人的评论,如facebook **php代码更新** <section class="panel-body"> "> 发表评论 $(文档).ready(函数(){ $('#comments').load('cajax.php'); 刷新(); }); 函数刷新() { setTimeout(函数(){ $('#comments').load('cajax.php'); 刷新(); }, 1000); } 如何在不刷新页面的情况下自动加载评论我知道它的作用 a

自动加载其他人的评论,如facebook

**php代码更新**

 <section class="panel-body">


">
发表评论
$(文档).ready(函数(){
$('#comments').load('cajax.php');
刷新();
});
函数刷新()
{
setTimeout(函数(){
$('#comments').load('cajax.php');
刷新();
}, 1000);
}
如何在不刷新页面的情况下自动加载评论我知道它的作用
ajax可以实现,但如何实现代码请帮助我们首先创建另一个名为comments.php的php文件或任何您想要的文件,然后剪切并粘贴从该文件中的DB获取注释的代码 在你想要显示注释的主文件中,创建一个div,id=“comments”或你想要的任何东西。在这个div中包括如下的新php文件

 <div id="comments">
<?php include'comments.php'; ?>   
</div> 

现在,在该代码上方粘贴以下javascript代码:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script type="text/javascript">
$(document).ready( function(){
$('#div_name').load('filename.php');
refresh();
});

function refresh()
{
    setTimeout( function() {
      $('#div_name').load('filename.php');
      refresh();
    }, 1000);
}
</script>

$(文档).ready(函数(){
$('#div_name').load('filename.php');
刷新();
});
函数刷新()
{
setTimeout(函数(){
$('#div_name').load('filename.php');
刷新();
}, 1000);
}

将div_名称替换为您的div和filename.php。使用您的文件名

您需要“加载更多按钮”这是演示页面和代码请查看我的问题如果您对主题的标题有误,“如何在不刷新页面的情况下发布评论”
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script type="text/javascript">
$(document).ready( function(){
$('#div_name').load('filename.php');
refresh();
});

function refresh()
{
    setTimeout( function() {
      $('#div_name').load('filename.php');
      refresh();
    }, 1000);
}
</script>