Updating JS element Every Second With Content From MySQL Database

Info.: This is Num Game with timer (countdown), the game is running every 15mins (900s) Non-Stop.

The problem is: How to do var GameID and var continuous updating on the page without manually refresh the page by myself on the Jquery/Ajax Code.

I tried with .val() (but work only with input), .text() and .html() need div/span. But can’t find the work way.

setInterval(InfoUp, 1000); - print the game id, but on the site where is

<span id="game_id"></span>

The JS Code is: Take time from database –> when time is zero, go to game_balls.php, and take the results of the game. The Balls script is here http://jsbin.com/nupaz/3/edit and Start all again

php/mysql in the same file with JS.

function gmtime() {
    return strtotime(get_date_time());
}
function get_date_time($timestamp = 0) {
        if ($timestamp)
                return date("Y-m-d H:i:s", $timestamp);
        else
                return gmdate("Y-m-d H:i:s", time());
}
$checkgames_b = mysqli_query($link, "SELECT gameid, next_time FROM history ORDER BY gameid DESC LIMIT 1") or die(mysqli_error($link));
$checkgames = mysqli_fetch_array($checkgames_b);
$game_id = $checkgames['gameid'];
$time_sec = strtotime($checkgames['next_time']) - gmtime(); //Here is Game Seconds for next start game

JS

$(this).ready(function(){
function InfoUp() {
    var stat = ["game_id_next","game_id"];
    var url = "whats_game_now.php";

    $.each(stat, function(i, key){
       $.post(url, {stats: key}, function(data) {
          $("#" + key).html(data);
       });
    });
}

var isWaiting = false;
var isRunning = false;
var seconds = 1;//one sec and we start
var continuous = <?echo$time_sec;?>; //take seconds info. from database
var countdownTimer;
var finalCountdown = false;
var GameID = <?echo$game_id;?>; //take last game id from database

function GameTimer() {
    var minutes = Math.round((seconds - 30) / 60);
    var remainingSeconds = seconds % 60;
    if (remainingSeconds < 10) {
        remainingSeconds = "0" + remainingSeconds;
    }
 document.getElementById('waiting_time').innerHTML = minutes + ":" + remainingSeconds;
    if (seconds == 0) {
        isRunning = true;
        seconds += continuous;
     $.ajax({
        url: 'game_balls.php',
        type: 'GET',
        //data : { GameID : 70 },
        data: "GameID="+GameID,
        success: function(data) {
        $('#table_for_balls').html(data);
        }
     });
    } else {
        isWaiting = true;
        seconds--;
    }
}
countdownTimer = setInterval(GameTimer, 1000);
setInterval(InfoUp, 1000);
});

Thanks for help

Delete please. I found Good way for my question.

Thanks any way.