Prevent stacking of AJAX-requests
<p>I've got a problem which I can't seem to solve. </p>

<p>I'm currently implementing a an AJAX-function similar to the one Twitter uses - that fetch new posts on scrolling.</p>

<p>The jQuery looks something like this: </p>

<pre><code>        $(window).scroll(function(){
            if($(window).scrollTop() == $(document).height() - $(window).height()){
                $('div#ajaxloader').show();
                $.ajax({
                    url: "loader.php?lastid=" + $(".container:last").attr("id"),
                    success: function(html){
                        if(html){
                            $("#main").append(html);
                            $('div#ajaxloader').hide();
                        }else{
                            $('div#ajaxloader').html('No more posts to show.');
                        }
                    }                   
                });
            }
        });
</code></pre>

<p>Now the problem; if the user scrolls really fast and the database is doing it's work quickly - the jQuery doesn't seem to be able to send the correct id as a query fast enough - which results in double-posts. </p>

<p>Anyone have a good idea on how to prevent this?</p>
