Skip to content

Instantly share code, notes, and snippets.

@sneycampos
Forked from amitavroy/infinitescroll.js
Created May 1, 2019 13:06
Show Gist options
  • Save sneycampos/f11c689f2137dc25ecd0455078714c9e to your computer and use it in GitHub Desktop.
Save sneycampos/f11c689f2137dc25ecd0455078714c9e 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