信息流拉取

<script type="text/javascript">




getData();
var stop=true;
var page=1;
$(window).scroll(function(){ 
    //$(window).height()浏览器可视界面高度
    //$(window).scrollTop()浏览器可视窗口顶端距离网页顶端的高度(垂直偏移)
    //$(document).height()整个网页的文档高度
    totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); 
    if($(document).height() <= totalheight){ 
        if(stop==true){ 
            stop=false; 
            getData();
        } 
    } 
});

function getData(){
    $.ajax({
        type: 'POST',
        url: "<?php echo url(array('m' => 'liao', 'c' => 'api', 'do' => 'getCash')); ?>",
        data: {page:page},
        dataType: 'json',
        success: function(data) {
            var html = '';
            if (data.code == 200) {
                page++;
                for (var i = data.data.length - 1; i >= 0; i--) {
                    html += '<div class="timess">' +
                    '<div class="timet">'+data.data[i].createtime+' | ¥'+data.data[i].total_fee/100+'元</div>' +
                    '<div class="bit"></div>' +
                '</div>' +
                '<div class="lne"></div>';
                }
                $('.content').append(html);
                stop=true;
            }else {
                html += '<div class="timess">' +
                    '<div class="timet"></div>' +
                    '<div class="bit">没有数据了</div>' +
                '</div>' +
                '<div class="lne"></div>';
                $('.content').append(html);
                stop=false;
            }
        },
        error: function() {
            alert('系统出错了,刷新后重试。');
        }
    }).always(function () {
        // stop=true;
    });
}
</script>
发布了34 篇原创文章 · 获赞 10 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/u014391889/article/details/83215061