Monday, August 27, 2012

Load Data while Scrolling Page Down with jQuery and PHP



click here complete source code download
<script type="text/javascript">
    var page = 1;
    function getFeedItems() {
        $('.loading').show();
        $.ajax({
            url : 'loadmore.php',
            data : 'page=' + page,
            type : 'GET',
            success: function(a) {
                if (a == '') {
                    $('#feed-list').append('<li>No more records found.</li>');
                    $(window).scroll(function() {});
                    $('.loading').hide();

                } else {
                    $('#feed-list').append(a);
                    $('.loading').hide();
                }
               
            }
        });
    }
    $(document).ready(function() {
        getFeedItems();
        $(window).scroll(function()
{
    if($(window).scrollTop() == $(document).height() - $(window).height())
    {
        page = page+1;
    getFeedItems();
    }
});

    });
</script>

<ul class="list" id="feed-list">
                        </ul>

create loadmore.php
and $_GET['page'];

No comments:

Post a Comment