First of all Hello!
In my website i have game, every 15min i have new draw, and when people come to website they see how much time is left.
It work Now (Jquery/Ajax):
- Take information every second from Memchached and Run.
- When time left is “00:00” => run some script and continue again (1.)
How to change this to other way ? To do time run, and without send query every second to check the time left. Or just optimization the code. Here is the code, that i use.
jQuery(function ($) {
function InfoTime() {
var stat = ['table_for_timer'];
var url = 'game_run_script.php?' + Math.random();
$.each(stat, function (i, key) {
$.post(url, {
cache: false,
stats: key
}, function (data) {
if (data === "00:00") {
$.ajax({
url: 'run_action_script.php?' + Math.random(),
type: 'GET',
cache: false,
data: '',
success: function (data) {
$('#showinfo').html(data);
$('#something').load('something.php?' + Math.random());
return false;
}
});
}
$("#" + key).html(data);
});
});
}
setInterval(InfoTime, 1000);
});
In this website i found running time left (like what i need) http://cafe.inbet.cc/keno u can see Time before start: 1:25 , but I do not understand how it works there.
Thanks