Display some of the entries and finish the rest when scrolling

Display a certain number of records, and when you scroll down the page, display the rest. On the example of audio recordings, friends, news and other things in contact. How can you do the same?

I’ve displayed 20 records from the database, and so that when scrolling down, the rest are displayed in turn.


Answer 1, authority 100%

The implementation is quite simple,

  1. Catch the onscrollevent of the window
  2. Check if the user is at the bottom of the page
  3. If yes, then load via ajax add. content

With jquery you get something like:

var page = 1; //  
$(window).scroll(function() 
{
     if  ($(window).scrollTop() == $(document).height() - $(window).height()) 
     {
          //  ,  
          page++; 
          $.ajax({
              type: "GET",
              cache: false,
              url: '[]?page=' + page,
              success: function(data) {
                   $('#container').append(data);
              }
          }
      }
});