jQuery 超屏加载

jQuery 超屏加载,当文档超出屏幕的高度时,加载最新下个列数据

$(window).scroll(function () {
    var height = $(document).height(); //页面的高度
    var keheight = $(window).height(); //浏览器可视的高度
    var sheight = $(document).scrollTop(); //滚动的高度
    var num = $('.pro_list a').length;
    if (height <= keheight + sheight) {
        $.post('/index.php/ajax-addlist.html', { type: 'class', id: '102', num: num }, function (data) {
            if (data == '1') {
                $('.loading span').html('无更多数据...');
            } else {
                $('.pro_list').append(data);
            }
            //alert(data);
        });
    }

});

$(function () {
    var height = $(document).height(); //页面的高度
    var keheight = $(window).height(); //浏览器可视的高度

    if (keheight >= height) {
        $('.loading span').html('无更多数据...');
    }
});

  

posted @ 2014-08-14 09:57  microsoftzhcn  阅读(345)  评论(0编辑  收藏  举报