function showChatNotifications(notifications) { $("#unreadChatlist").html(""); for (i in notifications) { $("#unreadChatlist").append(" \
  • \
    \ \
    \
  • \ "); } } function loadNotifications() { $.post( "API/loadChatNotifications.php" ).done(function(data) { if (data && data != "[]") { $("#unread-messages-section").show(); showChatNotifications(JSON.parse(data)); } else { $("#unread-messages-section").hide(); } }); setTimeout(loadNotifications, 10000); } $(document).ready(function() { loadNotifications(); });