<div id="xkxk"><a href="javascript:dr_loading();">加載完畢</a></div>
<script>
var dr_page = 1;
var nums = {$nums};
$('#xkxk').hide();
$(window).scroll(function(event) {
if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
dr_page++; // 加載下一頁的意思
$.get('{SITE_URL}index.php?s={MOD_DIR}&c=api&m=template&name=txt-list-data.html&catid={$catid}&page='+dr_page,
function (html) {
$('.txt-list-data').append(html); // 將返回的內(nèi)容追加到內(nèi)容區(qū)域
// 將返回的內(nèi)容追加到內(nèi)容區(qū)域
});
if (dr_page >= nums) {
$('#xkxk').show();
}//判斷 當(dāng)前頁是否大于總頁數(shù)
}
});
</script>最近有個(gè)客戶 有需求 自動加載下一頁 沒有了提示加載完畢。 另類的實(shí)現(xiàn)。歡迎高手再來指教 更好的辦法
$(document).ajaxStart(function(){ $(".xkxk").replaceWith("<a href='javascript:;'>正在加載…</a>") }).ajaxStop(function(){ $(".xkxk").replaceWith("<a href='javascript:dr_loading;'>加載更多</a>") })