.html() & setTimeOut

.html() & setTimeOut

Hi,

This is the scenario I want to create, Right now I want to do a timer effect. So I calling Timeout function if the condition is true. obj will minus it values and use .html(obj) to display. However, right now the timer wont update by itself.

Am I using .html() correctly? I try empty first before using html but wont works





$(document).ready(function() {
    setTimeout(function(){ Ajax(); },1000);
   
    function ActiveTimer(obj)
    {
        obj--;
        $('#item1').html(obj);
    }
   
    function Ajax()
    {
        var ajaxCounter= 0;
        for(i=0; i< c.length; i++)
        {
            for(w=0; w< c[i].length; w++)
            {
                if(c[i][w] < 0)
                c[i][w]= "false";
                
                if(c[i][w]=="false")
                ajaxCounter++;
                else
                ActiveTimer(c[i][w]);
            }
        }
        
        //Condition to stop setTimeout
        if(ajaxCounter!=productId)
        setTimeout(function(){ Ajax(); },1000);    
    }
})