jquery滾動條加載數據


//滾動條
 $(window).scroll(function () {
  var scrollTop = $(this).scrollTop();
  var scrollHeight = $(document).height();
  var windowHeight = $(this).height();
  var data = $("#n").text();
  console.log(data);
        if (scrollTop + windowHeight == scrollHeight) {
            //此處是滾動條到底部時候觸發的事件,在這里寫要加載的數據,或者是拉動滾動條的操作
           $.ajax({
                  url: basePath+'/daily/toDailyDebtNextPage.shtml',
                  type: 'GET',
                  dataType: "json",
                  //timeout: 15000,
                  cache:false,
                  data:data,
                      beforeSend: function (e){
                          
                      },
                      success: function(data, status){
                        var html = '';
                                var list = data.debtList;
                                             
                                for (var i = list.length - 1; i >= 0; i--) {
                              
                                  html += '<div class="list_box"><div class="con"><table><tr><td>標的類型</td><td class="r m">'+list[i].debType+'</td></tr><tr><td>借款人身份證號</td><td class="r no'+data.maxId+'">'+list[i].debtorIdentityNo+'</td></tr><tr><td>借款用途</td><td class="r">'+list[i].debtPurpose+'</td></tr><tr><td>借款金額(元)</td><td class="f_yellow r">'+list[i].loanReceiptAmt+'</td></tr></table></div></div>';
                              };
                              
                               $('#list').append(html);
                               geshi(data.maxId); 
                              
                                console.log(data);
                                var maxRecords = parseInt(data.maxRecords);
                                //var startId = 0;
                                var startId = parseInt(data.maxId)+1;
                                var userId = parseInt(data.userId);
                                var prodNo = data.prodNo;
                                var data ="userId="+userId+"&prodNo="+prodNo+"&startId="+startId+ "&maxRecords="+maxRecords;  
                                if(list.length<maxRecords)
                                  {$('#m').html("加載完畢..")};
                                $('#n').text(data);
                      },
                      error:   function(XMLHttpRequest,event,ajaxOptions, thrownError){
 
                      }
              });
        }
 });
 

 

原文地址:http://www.35ui.cn/post/20160311921.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM