pklauzinski / jscroll

An infinite scrolling plugin for jQuery.
http://jscroll.com/
1.11k stars 563 forks source link

Using with MySQL Data #21

Closed pottrell closed 10 years ago

pottrell commented 10 years ago

Is it possible to use jScroll with data from a database?

pklauzinski commented 10 years ago

That's generally the idea with dynamic, paginated content, so yes. Your backend will have to handle the serving of that data via asynchronous http request for jScroll to display the content on the page.

pottrell commented 10 years ago

My apologies, I'm very new to this really!

So I would do something along the lines of:

    <script type="text/javascript">
        $(document).ready(function(){
            $(".more").live('click',function(){
                $.ajax({
                    type : "POST",
                    url  : "loadmore.php",
                    beforeSend : function(){
                        var exhtml = $('#more').html();
                        $('.more').html('<img src="loader.gif" alt="Loading..." />');
                    },
                    success : function(html){
                        $('.more').remove();
                        $('#records').append(html);
                    }
                });
            });
        });
    </script>

load.php would have my php request?