I'm polling my server using jQuery's ajax function and then using that data to update a canvas. I poll the server once each second (this is not done using setInterval(), in case you're wondering... I did hear that is sometimes the source of these issues. The canvas is animated, and I keep track of the frame rate. I use this data to figure out when a second has elapsed). This isn't an issue in Chrome, but in Firefox and Maxthon Cloud (and to a MUCH MUCH lesser degree Opera), performance gradually grows worse and worse. I think it's the ajax calls, and I have NO IDEA how to fix the issue. Here is my "callServer()" function, if that's of any use. Thanks!
function callServer(action, json)
{
if(!json)
{
$.ajax({
type: 'POST',
url: 'okey.php.',
data: 'action=' + action,
cache: false,
success: function(data)
{
switch(action)
{
case 'ptv':
tilesValue = data;
break;
case 'ptc':
tilesColor = data;
break;
case 'tid':
//alert(data);
thisPlayerID = data;
break;
case 'pti':
playerTurnInfo = data;
//alert(data);
break;
case 'gs':
gameStatus = data;
break;
case 'steal':
alert(data);
break;
case 'draw':
alert(data);
break;
case 'testing':
alert(data);
break;
}
}
});
}
else if(json)
{
$.ajax({
type: 'POST',
url: 'okey.php.',
data: 'action=' + action,
dataType: 'json',
cache: false,
success: function(data)
{
switch(action)
{
case 'ptv':
tilesValue = data;
break;
case 'ptc':
tilesColor = data;
//alert(tilesColor.length);
break;
case 'pn':
playerNames = data;
break;
case 'pid':
playerIDs = data;
break;
case 'pts':
//alert("excellent");
turnStatuses = data;
break;
case 'ti':
tileIndeces = data;
//alert(tileIndeces.length)
break;
case 'dis':
//alert(parseInt(data[3]));
discarded = data;
//alert(parseInt(discarded[3]));
break;
}
}
});
}
}
Update: It is not the frequency of the calls that is causing the issue.
if (!json)
and thenelse if (json)
- you could just make theelse if (json)
beelse
. Also, you're going to have to show how you're calling this code. – Ian 2 days ago