How to clearInterval() in this code
<p>I'm trying to make a wall post like Facebook. I need to refresh the content div after every ten seconds and the div shouldn't refresh while the user is typing a comment. The content is reloading but is not stopping. Actually, I want to stop it when i click <code>id = 'comments_option'</code>.</p>

<p>I tried this and called the function reload(uid) at <code>$(document).ready</code></p>

<pre><code>var intervalId = null;

function reload(uid) {
    intervalId = setInterval(function () {
        var ol = $('#home_list');
        var start = ol.children().length;

        $.post('ajax/reloadhome.php', {
            uid: uid,
            start: start
        }, function (data) {
            $('#buzzfetch ul').html(data);
        });
    }, 5000);


    $('#comments_option').click(function () {

        clearInterval(intervalId);

    });
}
</code></pre>
