Created
March 25, 2013 11:44
-
-
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.
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
$(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