Reputation: 5170
How a notification can be shown after we are receiving a new message like FACEBOOK is displaying without refreshing a page. ( facebook is showing RED color notification after receiving a new message).
Thank You
Upvotes: 2
Views: 6335
Reputation: 1
If ive understood you correctly you need to look up a technology called AJAX, its a combination of JavaScript and XML which allows the sending and receiving of data behind the scenes ie without needed to refresh the page. Theres plenty of tutorials/information out there about it and its not difficult to get the hang of, hope this helps.
Upvotes: 0
Reputation: 992
There are two ways out there, you poll, or Comet.
After the number of new messages arrived to you, you can edit your DOM via javascript to show a red notification whereever you want.
Upvotes: 8
Reputation: 1760
Easiest way is to use jquery to update the content of a div at a sepecific interval...
#idofdivtoupdate
as it says.. the id of the div you want to auto update...
setinterval is in miliseconds.. (so 5000 checks every 5 seconds)
function updatecontent(){
$('#idofdivtoupdate').load('yourserverscript.php');
}
setInterval("updatecontent()", 5000 );
Upvotes: 1
Reputation: 5662
You need to use setInterval to periodically check for any new updates and then, if they are found, use ajax to pull in the message.
Upvotes: 3