web页面通过ajax无限下拉

来源:互联网 发布:php股票网站源代码 编辑:程序博客网 时间:2024/06/06 03:17
<script>
            $(function(){
                var i = 0 ;
                $(window).scroll(function(){
                    // 当滚动到最底部以上50像素时, 加载新内容
                    if ($(document).height() - $(this).scrollTop() - $(this).height()<270){
                        var myDate = new Date();
                        row = $('.rooms_show_ul').children('li').last().attr('data-row');
                        if(i != row){
                            jQuery.ajax({url:'/index.php',
                                type: 'GET', 
                                data:{act:'ajaxForHouses',row:row,date:myDate}, 
                                dataType: 'html', 
                                timeout: 1000, 
                                async : true,
                                error: function(){
                                }, 
                                success: function(result){
                                    $('.rooms_show_ul').append(result);
                                }
                            });
                            i = row;
                        }
                    }
                });
            });
        </script>
0 0
原创粉丝点击