var timerId = setInterval( .... );
clearInterval( timerId );
while(game_is_running){
update_game();
sleep(time);
}
var update = Date.now();
function f(){
var last = update;
update_game();
update = Date.now();
if(game_is_running) setTimeout(f, time - update + last);
}
f();
$.ajax({
type: "get",
url: 'http://rate-exchange.appspot.com/currency?from=RUB&to=KZT&q=1',
dataType: "jsonp",
success: function(data){
console.log(data);
},
error : function(data){
console.log(data);
}
});