I am trying to make a real time comment system.I have already made this by using jquery setTimeout. But problem is every interval of time page is refreshing, so I think this is not a good way.
Here is the code
function update_comment(){
setTimeout(function(){
$.getJSON("comment_fetch.php",function(data){
$.each(data.result,function(){
//console.log(this["pid"]);
$(".commentItem"+this["pid"]).append("<p class='message'><a class='name' href='#'><small class='text-muted pull-right'><i class='fa fa-clock-o'></i>"+this["dc"]+"</small><i class='fa fa-user'></i>"+this["un"]+"</a>"+this["c"]+"<a href='#' class='replyLink'><i class='fa fa-pencil'></i> Reply</a></p>");
});
$.each(data.pidcc,function(){
//console.log(this["pid"]+" "+this["pcc"]);
$("#cmnt_count"+this["pid"]).html("Comment ("+this["pcc"]+")");
});
});
update_comment();
},200);
}
have there any solution to make a real time comment system without using setTimeout ?