I'm creating a chat system and the problem is that when testing with two users, the secound user (entering the system) can see the first user (already loged in), but the first user will never see the next user(s) entering the system.
I know that the problem comes from the jquery, ajax call that I'm listing bellow. That code is responsible for creating a table with the users online. I think that the problem exists because the first time the code is run the table is created, but from there on the table is never recreated, that's why the users that appear online are never updated.
To solve the problem I tried to delete the div tag that holds the table with the users but it doesn't seem to work (I think the table is never recreated, or deleted.
This function is called every second, just like others that are working
Can you please help? Am I doing something wrong when deleting the div tag, or is this idea impossible to be placed into practice?
$.ajax({
type: 'POST',
url: 'http://www.game4tress.com/val.php',
data: 'server=' + serverlocation,
cache: false,
success: function(result) {
if(result){
resultObj = eval (result);
$( "#idMR" ).empty();
var ind;
var currVal;
var countCols;
var bolEnd=true;
var strValueHtml="<div id='idMR'><table id='GetPlayer'><tr>";
var ColNr=7;
var idClick=0;
ind=0;
countCols=0;
var myArray = result;
$( '#tblOnlinePlayers').html('');
$.each(result, function(i, item) {
if((ind>1)&& (ind<result.length-2))
{
if(item=="$")
{
strValueHtml= strValueHtml + "</td>";
bolEnd=true;
if(countCols>=ColNr)
{
strValueHtml= strValueHtml + "</tr>";
}
countCols++;
}
else
{
if(countCols>=ColNr)
{
strValueHtml= strValueHtml + "<tr>";
countCols=0;
}
if(bolEnd)
{
idClick++;
strValueHtml= strValueHtml + "<td id='A" + idClick + "'>";
bolEnd=false;
}
strValueHtml= strValueHtml + item;
}
}
ind++;
});
strValueHtml= strValueHtml + "</tr></table></div>";
$('#UsersOnline').html(strValueHtml);
}else{
alert("error");
}
}
});
My thanks in advanced