Skip to content

Instantly share code, notes, and snippets.

@amitavroy
Created March 25, 2013 11:44
Show Gist options
  • Save amitavroy/5236605 to your computer and use it in GitHub Desktop.
Save amitavroy/5236605 to your computer and use it in GitHub Desktop.
This code is used to generate an infinite scroll. It appends the new data to the container. Need to work on providing an animation when the data is being fetched.
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
// calling the function to get the ajax data
loadMore();
}
});
function loadMore() {
$.ajax({
url: base_url + "/infscroll/get_inf_scroll_ajax",
async: false,
type: "POST",
data: "page=2",
dataType: "html",
success: function(data) {
$('div#content-container').append(data);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment