Created
June 14, 2016 14:57
-
-
Save Ammly/be68862b1884c19281715ce25348245d to your computer and use it in GitHub Desktop.
Reload list items every 30 seconds. The php functions are getting the users from mysql db (working correctly)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<div class="usr_content"> | |
<ul> | |
// list item to reload | |
<li class="disabled success" id="reload">Online Users | |
<?php | |
$onlineUsers = $demo->getOnlineUsers($current_user, $user_company); | |
foreach ($onlineUsers as $key => $onlineUser) { | |
if (is_array($onlineUser)){ | |
$cls = $key == 0 ? 'selected' : ''; | |
?> | |
<ul id="users"> | |
<li id="<?= $onlineUser['id']?>" > | |
<label><?= $onlineUser['username'] ?> | |
<img src="assets/images/bullet_green.png" alt="onlines"> | |
<small>online</small></label> | |
</li> | |
</ul> | |
<?php | |
} | |
} | |
?> | |
</li> | |
// | |
<li > All Users | |
<?php | |
$users = $demo->getAlliUsers($user_company); | |
foreach ($users as $key => $user) { | |
if (is_array($user)){ | |
$cls = $key == 0 ? 'selected' : ''; | |
?> | |
<ul id="users"> | |
<li id="<?= $user['id']?>" > | |
<label><?= $user['username'] ?></label> | |
<img src="assets/images/bullet_yellow.png" alt="onlines"> | |
<small>offline</small></label> | |
</li> | |
</ul> | |
<?php | |
} | |
} | |
?> | |
</li> | |
</ul> | |
</div> | |
<script> | |
//reload #users every 30 sec | |
var $online_users = $("#reload"); | |
setInterval(function () { | |
$online_users.load("index.php #reload"); | |
}, 30000); | |
</script> |
If its only a component then you need to .empty()
#reload
element first before calling .load()
Just the component. <li class="disabled success" id="reload">
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does the whole page reload or is it just a component in the page that reloads?