Calling nested function from nested setInterval in an Object Namespace environment
<p>I have this following piece of code:</p>

<pre><code>var stats = {
....,
checkExistance :
function(url){
    var newUrl = url.substring(0, url.lastIndexOf("/")) + "/asyncCheckChartExistance";
    var xhrObj = stats.getXhr();

    var poolInterval = setInterval("poll()", 100);

    function poll(){
        xhrObj.open("GET", newUrl, true);
        xhrObj.send(null);

        xhrObj.onreadystatechange = function(){
            if(xhrObj.readyState === 4 &amp;&amp; xhrObj.status === 200){
                if (xhrObj.responseText.length === true){
                    console.log("Exists!");
                    clearInterval(poolInterval);
                } else {
                    console.log("Not Yet!");
                }
            }
        }
    }
},
}
</code></pre>

<p>I created the stats namespace. In this namespace I'm trying to create a function which polls the server every second. I should access this function this way: <code>stats.checkExistance(myUrl)</code>.</p>

<p>However it seems that the setInterval function is not able to see the <code>poll()</code> function. I know that this is normal behavior taking in consideration that these are nested inside another function. </p>

<p>If I were to write this in the Global namespace there would be no problem but I'm interested to make this work in this kind of namespace. Any ideas? Thanks!</p>
