有人可以帮我解释这段代码的无尽页面脚本吗?

时间:2018-03-21 19:43:51

标签: jquery infinite-scroll

我想使用这个脚本创建多个无限页面 - 但是我似乎只能创建两个页面。谁能告诉我我做错了什么?



var counter = 0;
$(window).scroll(function() {
  if ($(window).scrollTop() == $(document).height() - $(window).height() && counter < 4) {
    appendData();
  }
});

function appendData() {
  var html = '';
  for (i = 0; i < 1; i++) {
    html += '';

  }
  if (counter < 1)
    $('#myScroll').append('<? include_once 'GNC-10';?>');
  counter++;
  if (counter == 3)
    $('#myScroll').append('<? include_once 'GNC-2';?>');
  counter++;

}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

                                                                              var counter=0;
    $(window).scroll(function () {
        if ($(window).scrollTop() == $(document).height() - $(window).height() && counter < 4) {
            appendData();
        }
    });
    function appendData() {
        var html = '';
        for (i = 0; i < 1; i++) {
            html += '';

        }
        if(counter < 1)
        $('#myScroll').append('<? include_once 'GNC-10.php';?>');
        counter++;
        if(counter > 2)
        $('#myScroll').append('<? include_once 'GNC-1.php';?>');
        counter++;
        if(counter == 3)
        $('#myScroll').append('<? include_once 'GNC-2';?>');
        counter++;

         }