Here are some ways:
Freemasonry Endless Scroll http://desandro.com/demo/masonry/docs/infinite-scroll.html
Cpde Sample:
$wall.infinitescroll({ navSelector : '#page_nav', // selector for the paged navigation nextSelector : '#page_nav a', // selector for the NEXT link (to page 2) itemSelector : '.box', // selector for all items you'll retrieve loadingImg : 'img/loader.gif', donetext : 'No more pages to load.', debug: false, errorCallback: function() { // fade out the error message after 2 seconds $('
AJAXian Way (without plugins) http://ajaxian.com/archives/implementing-infinite-scrolling-with-jquery
code:
//Scroll Detection $(window).scroll(function(){ if ($(window).scrollTop() == $(document).height() - $(window).height()){ lastPostFunc(); } }); //Loading More content function lastPostFunc() { $(’div#lastPostsLoader’).html(’<img src="bigLoader.gif"/>’); $.post("scroll.asp?action=getLastPosts&lastID=" + $(".wrdLatest:last").attr("id"), function(data){ if (data != "") { $(".wrdLatest:last").after(data); } $(’div
Infinite Scroll jQuery Plugin (Original WordPress Plugin) http://www.infinite-scroll.com/infinite-scroll-jquery-plugin/
Code example:
// infinitescroll() is called on the element that surrounds // the items you will be loading more of $('#content').infinitescroll({ navSelector : "div.navigation", // selector for the paged navigation (it will be hidden) nextSelector : "div.navigation a:first", // selector for the NEXT link (to page 2) itemSelector : "#content div.post" // selector for all items you'll retrieve }); All options // usage: // $(elem).infinitescroll(options,[callback]); // infinitescroll() is called on the element that surrounds // the items you will be loading more of $('
Loading content when scrolling with jQuery (another example without PLugin) http://www.webresourcesdepot.com/load-content-while-scrolling-with-jquery/
code:
function lastPostFunc() { $('div#lastPostsLoader').html('<img src="bigLoader.gif">'); $.post("scroll.asp?action=getLastPosts&lastID=" + $(".wrdLatest:last").attr("id"), function(data){ if (data != "") { $(".wrdLatest:last").after(data); } $('div#lastPostsLoader').empty(); }); }; $(window).scroll(function(){ if ($(window).scrollTop() == $(document).height() - $(window).height()){ lastPostFunc(); } });
source share