无限滚动在IE中返回多个结果


Infinite scroll return multiple results in IE

我为我的网站创建了一个简单的无限滚动,在底部滚动时会显示更多图像。它适用于Chrome,但是当我在Internet Explorer上测试它时,加载程序会多次显示结果。我不知道错误在哪里。

这是我的jQuery代码:

$(document).ready(function(e){
    $(document).scroll(function(){
        if($(window).scrollTop() + $(window).height() ==    $(document).height()){
            var pictureCount = $(".Picture-1A").length;
            $.get('ajax/home-pagination.php', {off_set:pictureCount}, function(data){
                $("#homeContent").append(data);
            });
        }
    });
});

我将off_set发送到php页面,该页面将返回带有新图片的数据并将其附加到页面末尾

这应该有效:

首先实现去抖动到你的页面的CDN

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js"></script>

然后

在滚动函数中,添加如下去抖动函数:

$(window).scroll($.debounce(100, function(){ /* function */ }));

希望这也对你有用。 :)