How to show alert only once in jQuery
<p>I have a jquery function which loads more post when user scroll below every time</p>

<p>here is the jquery code</p>

<pre><code>$(function() {
    var $timeline = $('#tupdate'),
        $spinner = $('#loading').hide();

    function loadMore() {
        $(window).unbind('scroll.posts');
        $spinner.show();
        $.ajax({
            url: "/ajax/loadmore?lastPost=" + $(".pointer:last").attr('id'),
            success: function(html) {
                if (html) {
                    $timeline.append(html);
                    $spinner.hide();
                } else {
                    $spinner.hide();
                    bootbox.alert('No more post available');
                }
                $(window).bind('scroll.posts', scrollEvent);
            }
        });
    }
    //lastAddedLiveFunc();
    $(window).bind('scroll.posts', scrollEvent);

    function scrollEvent() {
        var wintop = $(window).scrollTop(),
            docheight = $(document).height(),
            winheight = $(window).height();
        var scrolltrigger = 0.95;
        if ((wintop / (docheight - winheight)) &gt; scrolltrigger) loadMore();
    }
});
</code></pre>

<p>Now the problem is whenever user scroll down popup is shown everytime which irritates the user, how can i alert only once?</p>

<p>here is what I've tried</p>

<pre><code>if (!g) {
    var g = 1;
    bootbox.alert('No more Post');
}
</code></pre>

<p>but still it keeps on showing alert every time i scoll down</p>