在没有使用ajax刷新的情况下自动获取数据

时间:2016-01-10 19:38:32

标签: javascript php jquery ajax

我正在尝试使用php jQuery和ajax创建一个会话系统。 我使用以下jQuery与php一起处理ajax帖子。

 function replyToStatus(sid,user,ta,postuser){
    var data = $('#'+ta).val(); 
    if(data.trim() == ""){
        alert("Please type a reply before you submit.");
        return false;
    }else{
    var dataString = 'action=status_reply&sid='+sid+'&user='+user+'&postuser='+postuser+'&data='+data;
    $.ajax({
        type: "POST",
        url: location.href,
        data: dataString,
        cache: false,
        success: function(response){
          $('#'+ta).val("");
          $( "#conrep_"+sid ).append( '<li><div class="comment-user-image-container"><div class="user-image" style="background:url(\'imagesrc.jpg\');"></div></div><div class="comment-content"><h5><a href="">admin </a>'+data+'</h5><img class="scaledImageFitWidth img" src="userimagesrc.jpg"></div></li>');

        }
    });

}
}

此代码会立即将帖子显示给发布帖子的当前用户(user1)。但是,对于在此用户(user1)发布后未查看该页面的所有其他用户,该帖子赢了&直到他们刷新为止。 我的问题是如何创建一个系统,自动向所有用户显示此帖子,或者如何处理此问题。 感谢您的回复:)

0 个答案:

没有答案