Refresh list (getJSON and setTimeout) without intermittent effect
hi,
I'm creating a list of online users.
the problem is that when I refresh the list with setTimeout, the list of users disappears for less then a second and then reappear.
I this because this is the time to get data from the server
this is my code:
- function getUOL() {
- $("#online_box ul").empty();
- $.getJSON("/uol.php?action=getUOL&tipo=1", function(data) {
- $.each(data, function(i, utente) {
- $("#online_box ul").append('<li><a href="/community/profilo.php?ID='+utente.IDUtente+'">'+utente.user+'</a></li>');
- });
- setTimeout('getUOL()', 5000);
- });
- }
there is a way to refresh list without have this "Intermittent effect"?
perhaps the problem is the line $("#online_box ul").empty(), but how can I update all list without clear all?
Thank you.