滚动到页面末尾后添加 JQuery 微调器

Add JQuery spinner after scrolling to end of page

本文关键字:JQuery 添加 滚动      更新时间:2023-09-26

我有以下代码将更多内容附加到 Div 中,但不确定在哪里添加图像加载器,以便在添加新内容之前显示在页面底部。

$(window).scroll(function () {
    if ($(window).scrollTop() == $(document).height() - $(window).height()) {   
    $.getJSON("http://howtodeployit.com/?json=recentstories", function(data) {
    newposts = data.posts.slice(currentPostcount, currentPostcount + desiredPosts);
    $.each(newposts, function(key, val) {
        //Append new contents
        $("#postlist").listview().listview('refresh');
        });
    });
}});

我已经尝试过这个,但它需要 AJAX:

beforeSend: function() { $('#loader').show(); },
complete: function() { $('#loader').hide(); },

试试这个。

$(window).scroll(function () {
    if ($(window).scrollTop() == $(document).height() - $(window).height()) {   
        $('#loader').show(); 
        $.getJSON("http://howtodeployit.com/?json=recentstories", function(data) {
            $('#loader').hide(); 
            $.each(data, function(key, val) {
                //Append new contents
                $("#postlist").listview().listview('refresh');
            });
        });
    }
});