如何创建像facebook这样的通知警报? [英] How to create Notification Alert like facebook?

查看:64
本文介绍了如何创建像facebook这样的通知警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个类似于facebook的通知提醒(小红色顶部的新消息通知)。我google了很多,但我找不到任何有用的东西。你能解释一下如何实现这个目标吗?

I want to create a notification alert similar to that of facebook (new message notification at the top in tiny red square). I googled a lot but i could not find anything helpful. Can you please explain how this can be achieved?

推荐答案

那么在那种情况下告诉你的确切,



社交网络中的通知概念,



您所做的每项活动......都有相关的实体(用户)。



无论何时执行活动,都会通知相关用户。





所以这个解决方案(我做的是),



在数据库中制作一个活动表,其中存储了相关的实体(用户)



用它和特定用户的通知表。当添加该活动的任何新元组



时(当任何用户执行该活动时),则相关的通知表



用户更新(告诉活动时间,发起者等)。





Finaly ,当用户打开他的帐户时,会从表中提取通知并显示



。这就是它可以做到的方式(不是最好的方式)。
Well in that case telling you in precise,

The concept of notifications in social network,

Every activity that you do ...has associated entities(users) with it.

And whenever the activity is performed the associated users are notified.


So the solution for this(what i do) is,

making a table of activity in database, which stores the entities(users) that are associated

with it and table of notifications for a perticular user. When any new tuple of that activity

is added(when any user performs that activity), then the notifications table for the associated

user is updated(telling about the activity time, and who initiated it,etc).


Finaly, when the user opens his account, the notifications are fetched from the table and

displayed. This is how it can be done(not the best way mind you).


这里将 - >

1)创建div或span你需要的地方显示通知说div为IDdivResult



Here Will go->
1)create div or span where you need to display the notification say div with id "divResult"



2)使用使用jquery post方法跟随javascript到http请求




2)use following javascript to http request using jquery post method

<script type="text/javascript">


document ).ready( function (){
window .setInterval( function (){
searchSearch(' helo') ;
}, 5000 );
});
function searchSearch(strVal){
alert(strVal);
(document).ready(function () { window.setInterval(function () { searchSearch('helo'); }, 5000); }); function searchSearch(strVal) { alert(strVal);


这篇关于如何创建像facebook这样的通知警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆