/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Ajax pages */ if ($("span.curr_page").length) { $("#loader").show(); } pulling = false; function grabPage(next_page) { if (next_page && pulling == false) { pulling = true; $.get(next_page, function(data) { var pages = data.split("<!--PAGES-->"); var new_pages = pages[1]; var posts = data.split("<!--POSTS-->"); var new_posts = posts[1]; $("div.post:last").after(new_posts); $("div#pagination").html(new_pages); pulling = false; }); } } $(window).scroll(function() { var currpos = 0.8*($(document).height() - $(window).height()); if ($("span.curr_page").length && $("#older").length) { if ($(window).scrollTop() > currpos) { grabPage($("#older").attr("href")); } } else { $("#loader").hide(); } });