index.php has this jquery code which loads notifications.inc.php into a div on the page every X amount of seconds
<script type='text/javascript'>
$(document).ready(function(){
var updatenotification = function(){
$('#notificationcontainer')
.load('notifications.inc.php')
.fadeIn("slow");
};
var auto_refresh = setInterval(function(){updatenotification();}, 5000);
updatenotification();
});
</script>
notifications.inc.php
<?PHP
if(notifications != 0){
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="box1r">
<tr><td height="25">Notifications</td></tr><tr><td colspan="2" bgcolor="#FFFFFF" height="11">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?PHP
if($item1 == 1){
echo 'AN HTML TEXT LINK HERE';
else if($item2 == 1){
echo 'AN HTML TEXT LINK HERE';
else if($item3 == 1){
echo 'AN HTML TEXT LINK HERE';
else if($item4 == 1){
echo 'AN HTML TEXT LINK HERE';
}
// ect. ect
?>
</table></td></tr></table>
<?PHP
}// end main block, only show the header "Notification" text if there is at least 1 notification ITEM to be shown
?>
Now this works well for me, to show when a user gets new messages, comments, photo comments, friend requests, things like that on there homepage.
My site is pretty high traffic and I would like to improve code in every area, (please save the pre-optimizing is evil speech, I have nothing but time and have been working on this site for 2 years, I want to make everything to the best of my ability)
SO I am thinking that this could be done better? FIrst I know I should re-code the tables to use DIV's but for now I am going to use this table setup on this particular page.
So to save bandwidth and performance, should I be using JSON or something instead of loading the contents of another page every 10 seconds or so?
If I should use JSON or something please explain a little bit, I am new to JS so I am not sure how to implement it exactly