0
$(function() {
   var startY = $('.borderwrap .post:last-child').position().top + $('.borderwrap .post:last-child').outerHeight();
     $(window).scroll(function(){
   checkY();
});
function checkY(){
   if( $(window).scrollTop() > startY ){
       var loadFrom = $('.pagination a').href;
     $('.borderwrap .extended').load(loadFrom  .borderwrap .post, function(response, status, xhr) {
 if (status == "error") {
    var msg = "Sorry but there was an error: ";
      $("#error").html(msg + xhr.status + " " + xhr.statusText);
      }
    });
   }
  }
   window.onLoad = checkY();
});

上面的代码我试图在无限滚动中加载内容。这是我到目前为止提出的脚本,唯一的问题是 `loadFrom' 上的数组 这个 html 看起来像这样

<div class="pagination">
  <a href="">1</a>
  <a href="/post3ksd99999">2</a>
  <a href="/post3ksd8888">3</a>
  <a href="/post3ksd98669">4</a>
</div>

所以我很难让数组在 .load() 函数中工作,而不是加载多个页面......我试过这个 -

for(i in loadFrom){
  $('.borderwrap .extended').load(loadFrom[i]  .borderwrap .post, function(response, status, xhr) {
if (status == "error") {
   var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
   }
 });
}

虽然这也不起作用。有什么建议么?

4

0 回答 0