最代码是轮询的方式实现的。
当用户a评论用户b的分享的时候,给用户b的私信数+1。
js去轮询3秒获取该用户的私信数。
js代码如下:remind = function(uuid,uid) {
$.ajax({
url : "/user/reminds.htm?uuid="+uuid+"&uid="+uid,
type : 'GET',
dataType : 'json',
success : function(json) {
if(json.error!=""){
return;
}
if(json.remindDescs.length==0){
return;
}
var template = $('#remind_template').html();
var html = Mustache.to_html(template, json).replace(/^\s*/mg, '');
$("#reminds").html("").append(html);
if($("title").html()==""){
$("title").html("您有新的提醒");
}else{
$("title").html("");
}
}
});
};
调用端代码:setInterval("remind(1550463811307520,1)",10000);