How to update an object property inside a SetTimeout call
<p>I looked around for a while but I didn't find the information I'm looking for.</p>

<p>I have the following question. I've my code that using the getstatus function executes a settimeout loop every 10 seconds. In this loop the ajax takes some variable from a php page and set some variables values. My problem is with the <em>value</em> property of the <strong>g</strong> object.</p>

<p>I starts to define the <strong>g</strong> object and then its property <strong>g.value</strong> to be global.</p>

<p>In the <em>gestatus</em> function I get the value I want from the ajax call (<strong>TA_1</strong>) and then the setTimeout function starts in which I update the <strong>g.value</strong> to the new <strong>TA_1</strong>. But in this way it doesn't seem to update the property value in the g object. I found the way to put the entire object definition after the setTimeout function, but in this way it creates new object at every loop. There is a way to refresh an object property inside a setTimeout loop? </p>

<p>Thanks to everybody.</p>

<p>Cheers</p>

<pre><code>  var g = new JustGage({
        id: "TA1",
        value: 0,
        min: 0,
        max: 1000,
        width: 100,
        height: 100,
        title: "Tsys A 1",
        });

    g.value = {};

    $(function() {

        getStatus();

    });

    function getStatus() {

        var TA_1    =   {};
        $.ajax({
        url: "getstatus2.php", 
        async: false,
        dataType: 'json',
        success: function(data) {
            TA_1    =   data.TsysA1;
            }
        });
        setTimeout("getStatus()",10000);
            g["value"] = TA_1;   
    }
</code></pre>