I'm wondering about the pros and cons of handling the auto-updating of a <div>
on server vs. client side. I'm using Apache with PHP but was just thinking of faking a push notification in Javascript like this:
setInterval(queryDatabaseForUnreadMessages, 60000);
function queryDatabaseForUnreadMessages(){
$.ajax({
url: "/messages/queryDatabaseForUnreadMessages",
success:function(data){
$('div#littleRedCircle').html(data);
}
});
}
I'd just like to set up a notification like Stackoverflow has done (little red circle with a number in it) to let people know they've received a new message if one exists. Is that simple AJAX/setInterval combo a bad idea?