var body_ = $(window);
            var indexPage = 2;
            var pageCount = <?php echo $pageCount;?>;
            var _ajaxRequest = true;
            body_.scroll(function () {
                var viewH = $(this).height(),//可见高度
                contentH = $(document).height(),//内容高度
                scrollTop = $(this).scrollTop();//滚动高度
                var _bottomDist = contentH - viewH - scrollTop;
                if(_ajaxRequest && _bottomDist <= 50 && indexPage <= pageCount){
                    _ajaxRequest = false;
                    $.ajax({
                        type: 'POST',
                        url: 'url?page=' + indexPage,
                        dataType: 'text',
                        success:function(data){
                            indexPage = indexPage + 1;
                            _ajaxRequest = true;
                            $('.div').append(data);
                        }
                    });
                }
            });

 

posted on 2015-10-28 17:21  浊浊然  阅读(304)  评论(0编辑  收藏  举报