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

标签 javascript jquery html css

我有以下代码可以将更多内容附加到 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');
            });
        });
    }
});

关于javascript - 滚动到页面末尾后添加 JQuery 微调器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19723708/

相关文章:

Javascript嵌套树排名

javascript - 如何从序列化形式构建自定义对象?

jquery - 将 HTML 表格导出到 Excel 时出现格式错误

php - 数据插入时自动输出数据库记录

html - 更改 JSF 表单的背景颜色

javascript - grunt 中的 less 文件观察器不更新 css

javascript - 如何用javascript触发css翻译动画

javascript - 使用 javascript 函数渲染 html 模板

c# - Web API 表单数据收集

html - 将文本 float 在导航栏右侧