Only run code when variable is not equal to null
<p>I'm having a problem. I have this code:</p>

<pre><code>setInterval(function() {
    $.ajax({ url: url, success: function(data, count){
        var obj = jQuery.parseJSON(data);
        var content = obj.results[0].content;
    }})
}, 2000)
</code></pre>

<p>Now this code is running every 2 seconds and making an ajax call. I keep getting the error that obj is null on this line: </p>

<pre><code>var content = obj.results[0].content;
</code></pre>

<p>I'm pretty sure it's because parseJson hasn't finished when the parser reaches this line. I need a way to say while <strong><em>obj = null</em></strong> don't run the <strong><em>var content = obj.results[0].content</strong>;</em> code.</p>

<p>Hope this makes sense. </p>
