vendredi 27 juin 2014

Polling New Message Alert/Notification


Vote count:

0




I am currently developing a web app that makes constant ajax calls (polls) to php to pull new 'tasks' from the database, sort of like how gmail/facebook checks for new email and messages. The current javascript code looks something like this:



doPoll();

function doPoll(){
$.post('ajax/tasks.php').done(function(data){
/* Append Tasks to HTML DOM */
}).always(function(){
setTimeout(doPoll, 5000);
});
}


see example:jQuery, simple polling example


I have gotten this to work well, my only problem now is that I would like to alert the user that they have a new 'task' if they are in a different tab. I know facebook and google do this by changing the Tab Heading from 'Facebook' to Something Like 'Facebook(2)' indicating 2 new messages. This seems like the norm, as I've seen other websites do this yahoo, trello, etc. This is sufficient for what I need to do and I was wondering if anyone knew how to do this, specifically only notify when the user is in a different tab.



asked 40 secs ago






Aucun commentaire:

Enregistrer un commentaire