Last active
December 26, 2015 21:59
-
-
Save abhishek77in/7219546 to your computer and use it in GitHub Desktop.
Simple script for implementing endless scroll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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