自动更新 ajax 前置 div 中的注释计数



我要做的是自动更新由 ajax 构造的任何预置div 的注释计数。所以基本上替换了 ajaxed 响应div 注释打印

success: function(data) {
    $.each(data.posts, function(i, response) {
        $("#homestatusid").prepend("<div id='commentprint"+response['streamitem_id']+"'>Comments "+response['num']+"</div>")[
    }
});

我有一个名为ajaxcommentcount.php的页面。这就是响应的来源并替换注释打印。我只是不知道该怎么做。

好的,

我能够发送所需的数据并重新更新ajaxeddiv。

我在成功中添加了以下内容

timer = setInterval(function() {
        refreshCurrentTab(streamitem_id);
    }, 5000); refreshCurrentTab(streamitem_id);

然后调用 .load() 中的函数,将帖子 id 传递给返回并替换div。

 function refreshCurrentTab(streamitem_id)
    {
        $('#commentprint'+streamitem_id).load('ajaxcommentcount.php?var='+streamitem_id+'');
    }

最新更新