I'm trying to get a online/offline status update for a chatsystem. Currently I'm stuck on how to update a span in real time. I got things working but it keeps adding the value (person which is online) to my span. What I want to achieve is to have a static list of people (those who are inside my database), and next to it a green bullet if they are online.
This is my jQuery script:
function theStatus(type, msg){
$("#status").append(
"<span class='status "+ type +"'>"+ msg +"</span>"
);
}
function getStatus(){
$.ajax({
type: "get",
url: "php/ajax/status_users.php",
async: true,
cache: false,
timeout: 1000,
success: function(data){
theStatus("rt", data);
setTimeout(
getStatus,
1000
);
}
});
};
$(document).ready(function(){
getStatus();
});
All help is welcome!