index.php代码  
[html] view plaincopy
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
        <title>滚屏加载--无刷新动态加载数据技术的应用-www.corange.cn</title>  
        <style type="text/css">  
            #container{margin:10px auto;width: 660px; border: 1px solid #;}   
            .single_item{padding: 20px; border-bottom: 1px dotted #d3d3d3;}  
            .author{position: absolute; left: 0px; font-weight:bold; color:#39f}  
            .date{position: absolute; right: 0px; color:#}  
            .content{line-height:20px; word-break: break-all;}  
            .element_head{width: %; position: relative; height: 20px;}  
            .nodata{display:none; height:32px; line-height:32px; text-align:center; color:#; font-size:14px}  
        </style>  
        <script type="text/javascript" src="../jquery.js"></script>  
        <script type="text/javascript">  
            $(function() {  
                var winH = $(window).height(); //页面可视区域高度  
                var i = ;  
                $(window).scroll(function() {  
                    var pageH = $(document.body).height();  
                    var scrollT = $(window).scrollTop(); //滚动条top  
                    var aa = (pageH - winH - scrollT) / winH;  
                    if (aa < 0.02) {  
                        $.getJSON("result.php", {page: i}, function(json) {  
                            if (json) {  
                                var str = "";  
                                $.each(json, function(index, array) {  
                                    var str = "<div class=\"single_item\"><div class=\"element_head\">";  
                                    var str = str + "<div class=\"date\">" + array['date'] + "</div>";  
                                    var str = str + "<div class=\"author\">" + array['author'] + "</div>";  
                                    var str = str + "</div><div class=\"content\">" + array['content'] + "</div></div>";  
                                    $("#container").append(str);  
                                });  
                                i++;  
                            } else {  
                                $(".nodata").show().html("别滚动了,已经到底了。。。");  
                                return false;  
                            }  
                        });  
                    }  
                });  
            });  
        </script>  
    </head>  
    <?php   
    require_once('connect.php');   
    $user = array('demo1','demo2','demo3','demo3','demo4');   
    ?>   
    <div id="container">   
        <?php   
        $query=mysql_query("select * from comments order by id desc limit 0,15");   
        while ($row=mysql_fetch_array($query)) {   
        ?>   
        <div class="single_item">   
            <div class="element_head">   
                <div class="date"><?php echo date('m-d H:i',$row['addtime']);?></div>   
                <div class="author"><?php echo $user[$row['userid']];?></div>   
            </div>   
            <div class="content"><?php echo $row['content'];?></div>   
        </div>   
        <?php } ?>   
    </div>   
    <div class="nodata"></div>    result.php代码 [php] view plaincopy在CODE上查看代码片派生到我的代码片
<?php  
require_once('connect.php'); //连接数据库   
   
$user = array('demo1','demo2','demo3','demo3','demo4');   
$page = intval($_GET['page']);  //获取请求的页数   
$start = $page*;   
$query=mysql_query("select * from comments order by id desc limit $start,15");   
while ($row=mysql_fetch_array($query)) {   
    $arr[] = array(   
        'content'=>$row['content'],   
        'author'=>$user[$row['userid']],   
        'date'=>date('m-d H:i',$row['addtime'])   
    );   
}   
echo json_encode($arr);  //转换为json数据输出   
?>   connect.php代码 [php] view plaincopy在CODE上查看代码片派生到我的代码片
<?php  
$host="localhost";  
$db_user="root";  
$db_pass="";  
$db_name="demo";  
$timezone="Asia/Shanghai";  
  
$link=mysql_connect($host,$db_user,$db_pass);  
mysql_select_db($db_name,$link);  
mysql_query("SET names UTF8");  
?>  

Jquery鼠标滚动到页面底部自动加载更多内容,使用分页的更多相关文章

  1. Jquery+php鼠标滚动到页面底部自动加载更多内容,使用分页

    1.index.php <style type="text/css"> #container{margin:10px auto;width: 660px; border ...

  2. 当滚动条滚动到页面底部自动加载增加内容的js代码

    这篇文章主要介绍了如何使用javscript实现滚动条滚动到页面底部自动加载增加页面内容,需要的朋友可以参考下..1,注册页面滚动事件,window.onscroll = function(){ }; ...

  3. vue 实现滚动到页面底部开始加载更多

    直接上代码: <template> <div class="newsList"> <div v-for="(items, index) in ...

  4. jQuery+ajax实现滚动到页面底部自动加载图文列表效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. UWP-ListView到底部自动加载更多数据

    原文:UWP-ListView到底部自动加载更多数据 ListView绑定的数据当需要“更多”时自动加载 ListView划到底部后,绑定的ObservableCollection列表数据需要加载的更 ...

  6. vue使用H5实现滚动到页面底部时加载数据

    使用原生vue实现瀑布流,发现无法实现小程序那种滚动到地步触发加载效果,只能自己研究了 实现效果: 实现代码: 首先添加监听滚动事件 mounted() { window.addEventListen ...

  7. 实现Android ListView 自动加载更多内容

    研究了几个小时终于实现了Android ListView 自动加载的效果. 说说我是怎样实现的.分享给大家. 1.给ListView增加一个FooterView,调用addFooterView(foo ...

  8. Android ListView滑动底部自动加载更多

    直接上代码: // lv = (ListView) findViewById(R.id.lv); // // for(int i = 0;i < 50;i++){ // ls.add(" ...

  9. jquery 页面滚动到底部自动加载插件集合

    很多社交网站都使用无限滚动的翻页技术来提高用户体验,当你页面滑到列表底部时候无需点击就自动加载更多的内容.下面为你推荐 10 个 jQuery 的无限滚动的插件: 1. jQuery ScrollPa ...

随机推荐

  1. go tool proof

    echo list | go tool pprof -alloc_space gateway http://10.2.1.93:8421/debug/pprof/heap > abc.log e ...

  2. Lua函数之一

    LUA函数之一 函数声明: function foo(arguments) statements end 1.函数调用 调用函数的时候,如果参数列表为空,必须使用()表明是函数调用,例如: os.da ...

  3. SOA面向服务架构简述

    在上篇中我们简单谈了下架构设计中服务层的简单理解,在这里我们将继续服务层的架构,在本节我们将重点在于分布式服务.在分布式系统中表现层和业务逻辑层 并不处于同一物理部署,所以我们必须存在分布式服务,以契 ...

  4. DROP TABLE ** CASCADE CONSTRAINTS PURGE删除表的时候级联删除从表外键

    1.关于 cascade constraints 假设A为主表(既含有某一主键的表),B为从表(即引用了A的主键作为外键). 则当删除A表时,如不特殊说明,则 drop table A 系统会出现错误 ...

  5. eclipse-统计代码行数

    使用Eclipse可以方便的统计工程或文件的代码行数,方法如下: 1.点击要统计的项目或许文件夹,在菜单栏点击Search,然后点击File...  2.选中正则表达式(Regular express ...

  6. win7下搭建PHP环境

    一.安装软件 1.apache下载地址:http://httpd.apache.org/download.cgi 2.php下载地址:http://windows.php.net/download/ ...

  7. 如何让ThinkPHP的模板引擎达到最佳效率

    默认情况下ThinkPHP框架系统默认使用的模板引擎是内置模板引擎.内置模板引擎支持模板文件中采用php原生态代码和模板标签的混合使用.ThinkPHP官方开发文档说,这种默认的内置模板引擎的性能是高 ...

  8. Brackets(区间dp)

    Brackets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3624   Accepted: 1879 Descript ...

  9. 解决 MySQL Cluster 通过 某一个MySqld节点新建表时,其他 MySqld节点 看不到表内容的问题

    问题: 总共有 4 个MySqld节点,通过其中的一个节点新建表时,发现其他 MySqld节点 查不到表内容的问题,即表没有同步过来. 解决方案: 主要是因为新建表时,所选的 表引擎 错误导致的,只能 ...

  10. ThinkPHP 分页实现

    TP3.2框架手册,有一个数据分页,不过每次都要写太多的代码,还有中文设置等有些麻烦,做为程序开发者,有必要整理下: O.先看效果图 一.分页方法 /** * TODO 基础分页的相同代码封装,使前台 ...