I found this Jquery/Ajax call with timer but for my case, i think i cannot help.
I've more then 3 panels to update with ajax and this number will keep growing. If that request are make at same time i can resolve using http://api.jquery.com/jQuery.when/ but this panels have differents timers to be executed...
The first every 10sec. The second every 3sec. The third every 30sec.
It will reach at moment on every one will be executed at the same time... But how this will keep growing...
I've think in one way creating a stack that should be executed using http://api.jquery.com/jQuery.when/ every 1sec.
I believe that another alternatives to implement this...
Some one get different solution?
/**
* Method to display method information.
*/
function updateServerStatus()
{
/**
* Performs ajax request to return the json.
* NOTES: 'server.load.php' send a json object about server status using false to 'offline' and 'true' to 'online' status.
*/
$.ajax({
'url' : 'server.load.php',
'data' : 'json',
success : function(objServer)
{
/**
* Removes style showing color about status.
*/
$('#map-status, #char-status, #login-status').removeClass('label-danger').removeClass('label-success');
/**
* Check if map-server is offline.
*/
if(objServer.map == false)
{
$('#map-status').addClass('label-danger').html('Offline');
}
else
{
$('#map-status').addClass('label-success').html('Online');
}
/**
* Check if char-server is offline.
*/
if(objServer.char == false)
{
$('#char-status').addClass('label-danger').html('Offline');
}
else
{
$('#char-status').addClass('label-success').html('Online');
}
/**
* Check if char-server is offline.
*/
if(objServer.login == false)
{
$('#login-status').addClass('label-danger').html('Offline');
}
else
{
$('#login-status').addClass('label-success').html('Online');
}
}
});
/**
* Get into loop calling this after 10sec to keep updated.
*/
setTimeout(updateServerStatus, 10000);
};
@SOLVED
I've solved it using array stack.