How to get more records or data on scroll down of page in PHP like facebook?

Do you know How to display more records while scrolling the page down using JQuery and PHP?

If you are familiar with jQuery and PHP, then it is not hard nut to crack.

Have a look on below code and you can do the same. Include JQuery library File:

Include JQuery library File:
<script type=’text/javascript’ src=’’></script>


Create or call using a simple jQuery function in JS file (If you want to make the code separate).

[code lang=”js”]


function scrollFunc()
if($(window).scrollTop() == ($(document).height() – $(window).height())){

var offset = $(‘[id^=&quot;dataRow_&quot;]’).length;
var records = $(&quot;.totNum&quot;).text();


if(records != offset){

$(&quot;#loaderImg&quot;).html(‘&lt;img src=&quot;images/ajax-loader.gif&quot; /&gt;’);




function loadMoreRecords(offset){

// here we call ajax to add more records in our page.

type: ‘get’,
url: ‘loadMyPageRecords.php’,
data: ‘offset=’+offset,

success: function(data){

$(&quot;.loadData :last&quot;).after(data);


error: function(data){
alert(&quot;ajax response error…&quot;+data);






How simple !! Isn’t it?

If you still face any issue, post your comments.