Dynamic notifications using jQuery
- by sparkymark75
I'm currently building a homepage for our staff which is to be set as the homepage in their browser. I'm currently building the facility whereby nominated members of staff can send notifications to all staff. These will popup on their home page without the need for them to refresh the page.
I've currently got the code below which worked fine for 1 notification, but there may be more than 1 at a time waiting to be shown. I've switched to outputting json but I'm not sure how to modify my code to consume it.
I'm using the PeriodicalUpdater and jGrowl plugins to get this functionality, if there's better alternatives then feel free to sugget them.
$.PeriodicalUpdater({
url: 'getNotifications.aspx',
maxTimeout: 6000,
type: 'json'
},
function(data) {
var message = data;
if (message != '') {
$.jGrowl(message, { sticky: true });
}
});
As an additional piece of functionality, would it be possible to store in a cookie when a user has closed a notification so they don't see it again?
Thanks.