Jquery鼠标滚动到页面底部自动加载更多内容,使用分页
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鼠标滚动到页面底部自动加载更多内容,使用分页的更多相关文章
- Jquery+php鼠标滚动到页面底部自动加载更多内容,使用分页
1.index.php <style type="text/css"> #container{margin:10px auto;width: 660px; border ...
- 当滚动条滚动到页面底部自动加载增加内容的js代码
这篇文章主要介绍了如何使用javscript实现滚动条滚动到页面底部自动加载增加页面内容,需要的朋友可以参考下..1,注册页面滚动事件,window.onscroll = function(){ }; ...
- vue 实现滚动到页面底部开始加载更多
直接上代码: <template> <div class="newsList"> <div v-for="(items, index) in ...
- jQuery+ajax实现滚动到页面底部自动加载图文列表效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- UWP-ListView到底部自动加载更多数据
原文:UWP-ListView到底部自动加载更多数据 ListView绑定的数据当需要“更多”时自动加载 ListView划到底部后,绑定的ObservableCollection列表数据需要加载的更 ...
- vue使用H5实现滚动到页面底部时加载数据
使用原生vue实现瀑布流,发现无法实现小程序那种滚动到地步触发加载效果,只能自己研究了 实现效果: 实现代码: 首先添加监听滚动事件 mounted() { window.addEventListen ...
- 实现Android ListView 自动加载更多内容
研究了几个小时终于实现了Android ListView 自动加载的效果. 说说我是怎样实现的.分享给大家. 1.给ListView增加一个FooterView,调用addFooterView(foo ...
- Android ListView滑动底部自动加载更多
直接上代码: // lv = (ListView) findViewById(R.id.lv); // // for(int i = 0;i < 50;i++){ // ls.add(" ...
- jquery 页面滚动到底部自动加载插件集合
很多社交网站都使用无限滚动的翻页技术来提高用户体验,当你页面滑到列表底部时候无需点击就自动加载更多的内容.下面为你推荐 10 个 jQuery 的无限滚动的插件: 1. jQuery ScrollPa ...
随机推荐
- hibernate的pojo和xml文件
- Spark Streaming和Flume-NG对接实验
Spark Streaming是一个新的实时计算的利器,而且还在快速的发展.它将输入流切分成一个个的DStream转换为RDD,从而可以使用Spark来处理.它直接支持多种数据源:Kafka, Flu ...
- 老项目的#iPhone6与iPhone6Plus适配#iOS8无法开启定位问题和#解决方案#
本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处. iOS8的定位和推送的访问都发生了变化, 下面是iOS7和iOS8申 ...
- hadoop学习之一
Hadoop是一个由Apache基金会所开发的分布式系统基础架构.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群的威力进行高速运算和存储.Hadoop的框架最核心的设计 ...
- gen already exists but is not a source folder. Convert to a source folder or rename it.
异常提示: gen already exists but is not a source folder. Convert to a source folder or rename it. 错误原因 ...
- bellman ford优先队列优化简介模板
#include<iostream>#include<cstdio>#include<utility>#include<queue>#include&l ...
- django-cms 代码研究(五)深入(代码结构)
前言: 前戏已经做得比较充分了,下面我们开始步入正题. 代码结构: cms |--admin (猜测是admin界面的二次开发和改良) |--cache (猜测是缓存机制的处理) |--extensi ...
- 【Python】Django Model 怎么使用 UUID 作为主键?
>>> import uuidprint uuid.uuid3(uuid.uuid1(), 'python.org') >>> # make a UUID base ...
- 《ASP.NET MVC4 WEB编程》学习笔记------Web API
本文截取自情缘 1. Web API简单说明 近来很多大型的平台都公开了Web API.比如百度地图 Web API,做过地图相关的人都熟悉.公开服务这种方式可以使它易于与各种各样的设备和客户端平台集 ...
- 查看Eclipse中的jar包的源代码:jd-gui.exe
前面搞了很久的使用JAD,各种下载插件,最后配置好了,还是不能用,不知道怎么回事, 想起一起用过的jd-gui.exe这个工具,是各种强大啊!!! 只需要把jar包直接扔进去就可以了,非常清晰,全部解 ...