setInterval and clearInterval not working with if()
<p>I am trying to do an AJAX refresh every 7 seconds on some data coming into an AJAX results <code>div</code>. </p>

<p>I need to control when it happens as I have lots of events like text editing and draggable stuff done through jQueryUI. I set up a function with a condition and an <code>if</code> statement to either set up an interval or clear it depending on the condition. </p>

<p>But my function seems to recognise a true state but not a false one. Any ideas or is their a better way to achieve what I want?  Many thanks for your time!</p>

<pre><code>var intervalStart = true;

function setupAjaxInterval(condition){
    if (condition == true) {
        var refreshContent = setInterval(function() {
            var datastring = 'refreshpage=true&amp;projid=' + proj_id + '&amp;uid=' + uid;
            ajaxUploadData(datastring);
            alert('pagerefresh');
        }, 7000);
    }
    else if (condition == false) {
        clearInterval(refreshContent);
        alert('nofresh');
    }
}

setupAjaxInterval(intervalStart);
//works for true but not false.
</code></pre>
