jquery實現滾動到頁面底部時無限載入內容的代碼,jquery載入

來源:互聯網
上載者:User

jquery實現滾動到頁面底部時無限載入內容的代碼,jquery載入

由於時間關係沒有整理封裝,有空的時候再把他做成一個外掛程式。但複製下來修改一下是可以用的。以下為執行個體:

var p="{$other.p}";if(p=="") p=1; var stop=true;//觸發開關,防止多次呼叫事件 $(window).scroll(function() {        //當內容滾動到底部時載入新的內容 100當距離最底部100個像素時開始載入.      if ($(this).scrollTop() + $(window).height() + 100 >= $(document).height() && $(this).scrollTop() > 100) {                      if(stop==true){              stop=false;              p=p+1;//當前要載入的頁碼                canshu="?t={$other.t}&p="+p+"&cid={$other.cid}";               //載入提示資訊               $("#showlists").append("<li class='ajaxtips'><div style='font-size:2em'>Loding.....</div></li>");               $.get("__URL__/nextpage"+canshu,function(data){                   $(".ajaxtips").hide();                   $("#showlists").append(data);//把新的內容載入到內容的後面                   stop=true;               })         }      }    }); 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.