Skip to content

Instantly share code, notes, and snippets.

@abhishek77in
Last active December 26, 2015 21:59
Show Gist options
  • Save abhishek77in/7219546 to your computer and use it in GitHub Desktop.
Save abhishek77in/7219546 to your computer and use it in GitHub Desktop.
Simple script for implementing endless scroll
var offset = 4;
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > ($(document).height() - 150)) {
loadMore(offset);
offset = offset + 4;
}
});
function loadMore(offset) {
$.ajax({
url: '/load_more',
data: { offset: offset },
async: false,
cache: false,
timeout: 30000,
success: function (result) {
$('.product-grid').append(result);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment