$(document).ready(function(){ // .loading is a div at the bottom of the screen. Only display if there are additional records able to be loaded if ($('.loading').length > 0) { $(window).scroll(function() { if ($(window).scrollTop() > $(document).height() - $(window).height() - 50) { $('.loading').text("Loading more products") // Fetch more records by pulling either JSON or straight HTML from the server // Set the html for these records to a variable called additionalRecordsHtml $('.results').append(additionalRecordsHtml) } }) } }