function showNotifications(notifications, id) { $("#" + id).html(""); for (i in notifications) { $("#" + id).append(" \
  • \
    \ \
    \
  • \ "); } } function loadNotifications() { $.post( "API/loadFriendRequestNotifications.php" ).done(function(data) { if (data && data != "[]") { showNotifications(JSON.parse(data), "friendrequestslist"); } }); $.post( "API/loadChatNotifications.php" ).done(function(data) { if (data && data != "[]") { showNotifications(JSON.parse(data), "unreadChatlist"); } }); setTimeout(loadNotifications, 10000); } $(document).ready(function() { loadNotifications(); });