我正在处理的网站信息中心上的新闻Feed包含来自不同用户的多个项目;也可以评论。但是,每当您在每个帖子下写评论时,它只会发布到Feed顶部的帖子(最新的帖子)。按回车键即可立即发布评论,然后运行此RSS代码,该代码位于index.php页面上。
$(function(){
$('#comment_body').live( 'keypress' , function (e) {
var boxVal = $(this).val();
var sendTo = $('#to_id').val();
if ( e.keyCode == '13' ) {
e.preventDefault();
$.post( 'instantcom.php' , { 'comment_body' : boxVal , 'activity_id' : sendTo } , function () {
// reload data or just leave blank
} );
$('#comment_body').val('');
}
} );
});
然后,每篇帖子的评论框的HTML如下:
<p align="center" style="height:45px;">
<input type="text" name="comment_body" id="comment_body" style="margin-top:12px;border:1px solid blue !important;width:329px;height:21px;" />
<span class=" glyphicons-icon camera" style="position:relative;bottom:50px;left:155px;"></span></p>
<input name="type" type="hidden" value="a" />
<input name="activity_id" id="to_id" type="hidden" value="' . $act_item_id . '" />
'。 $ act_item_id。 '只是一个PHP变量,它包含状态更新的唯一ID。
那么,关于为什么评论只发布到最近的帖子而不是他们要发布的帖子的任何想法?
答案 0 :(得分:0)
您正在使用ID来识别您要评论的帖子? to_id对吗?嗯,这是页面上的id,id应该是页面唯一的。