Using Javascript to detect the bottom of the window and ignoring all events when a request is loading
<p>I have an anonymous function to detect the user has scrolled to the bottom of the window. Inside of the anonymous function, I have a call to a database that takes a while to complete.</p>

<pre><code>var allowing_more = 1;

$(window).scroll(function() {
    if (allowing_more == 1){
        if ($(window).scrollTop() + $(window).height() == $(document).height()) {
            allowing_more = 0;
            //query
            allowing_more = 1;
        }
    }
});
</code></pre>

<p>In this time, if the user scrolls to the bottom of the window again, it seems a queue is made holding the occurences the user scrolled to the bottom of the window while the query was loading. Upon completing of the query, these occurences are then executed.</p>

<p>I have a boolean statement to detect if the anonymous function is accepting more query requests but this seems to be ignored.</p>

<p>Is there some sort of way to ignore an anonymous function temporarily and re-enable it?</p>
