sliceruk
sliceruk

Reputation: 127

Jquery load more on scroll

I am trying to load data from load_second.php into result div. When I scroll down on first time it loads the data from load_second.php, however, I want to keep that data and when I scroll again it should load more data. Any help would be greatly appreciated.

<script type='text/javascript'>$(window).scroll(function(){ 
    if ($(window).scrollTop() == $(document).height() - $(window).height()){

        $('#result').load('load_second.php');

    }
});
</script>

<div id='result'></div>

Upvotes: 0

Views: 306

Answers (1)

Stanley
Stanley

Reputation: 5127

You can't append the content with load() method. Use get() to retrieve the data and append it to the div.

$.get('load_second.php', function(data) {
    $('#result').append(data);
});

Upvotes: 1

Related Questions