html:
  <div id="more">
<div class="single_item">
<div class="date"></div>
<div class="author"></div>
<div class="title"></div>
</div>
<a href="javascript:;" class="get_more"></a>
</div>
<div id="nomore" style="text-align:center;color:gray"></div>

$(document).ready(function() {

     var totalPage = {$totalPage};//总页数
var page = {$page}; //起始页
var pageSize = {$pageSize} //每页显示个数
$(window).scroll(function() {
if(totalPage-page>){
//滚动条到达底部加载
if ($(document).scrollTop() >= $(document).height() - $(window).height()) { setTimeout(function() {
$.ajax({
type: 'GET',
url: '?m=wap&c=vedio&a=art_more&typeid=93&yp=128&pageNum='+(page+),
success:function(data){
var msg=eval(data);
$.each(msg, function (i, item) {
$('.art-list').append("<li><a href="+item.art_link+">"+item.title+"</a></li>");
});
page=page+;
},
error:function(data){
$("#nomore").html("加载失败...");
setTimeout(function() {
$("#nomore").html();
}, );
}, }); }, );
}
}else{
$("#nomore").html("我是有底线的...");
setTimeout(function() {
$("#nomore").empty();
}, );
}
});
}); php:
// 连接数据库
require_once('connect.php'); $last = $_POST['last'];
$amount = $_POST['amount']; $query = mysql_query("select * from article order by id desc limit $last,$amount");
while ($row = mysql_fetch_array($query)) {
$sayList[] = array(
'title' => $row['title'],
'author' => $row['id'],
'date' => date('m-d H:i', $row['addtime'])
);
}
echo json_encode($sayList);

返回json数据 [
{
"title": "xxx",
"author": "",
"date": "04-04 10:34"
},
{
"title": "xxx",
"author": "",
"date": "04-04 09:52"
},
{
"title": "xxx",
"author": "",
"date": "04-04 09:18"
},
{
"title": "xxx",
"author": "",
"date": "04-03 23:44"
},
{
"title": "xxx",
"author": "",
"date": "04-03 23:09"
},
{
"title": "xxx",
"author": "",
"date": "04-03 22:33"
},
{
"title": "xxx",
"author": "",
"date": "04-03 20:25"
},
{
"title": "xxx",
"author": "",
"date": "04-03 08:26"
},
{
"title": "xxx",
"author": "",
"date": "04-02 21:56"
},
{
"title": "xxx",
"author": "",
"date": "04-02 08:52"
}
] jquery.more.js /**
* 调用方法: $('#more').more({'url':'data.php'});
* amount 每次显示记录数
* address 请求的地址
* format 接受数据的格式
* template html记录DIV的class属性
* trigger 触发加载更多记录的class属性
* scroll 是否支持滚动触发加载
* offset 滚动触发加载时的偏移量
* data 自定义参数
* loading 加载时显示
*/
(function($) {
var target = null;
var template = null;
var lock = false;
var cur_last = ;
var variables = {
'last' :
}
var settings = {
'amount' : '',
'address' : 'comments.php',
'format' : 'json',
'template' : '.single_item',
'trigger' : '.get_more',
'scroll' : 'false',
'offset' : '',
'data' : {},
'loading' : '加载中...'
}
var methods = {
init: function(options) {
return this.each(function() {
if (options) {
$.extend(settings, options);
}
template = $(this).children(settings.template).wrap('<div/>').parent();
template.css('display', 'none');
$(this).append('<div class="loading">' + settings.loading + '</div>');
template.remove();
target = $(this);
if (settings.scroll == 'false') {
$(this).find(settings.trigger).bind('click.more', methods.get_data);
$(this).more('get_data');
} else {
if ($(this).height() <= $(this).attr('scrollHeight')) {
target.more('get_data', settings.amount * );
}
$(this).bind('scroll.more', methods.check_scroll);
}
})
},
check_scroll: function() {
if ((target.scrollTop() + target.height() + parseInt(settings.offset)) >= target.attr('scrollHeight') && lock == false) {
target.more('get_data');
}
},
debug: function() {
var debug_string = '';
$.each(variables, function(k, v) {
debug_string += k + ' : ' + v + '\n';
})
alert(debug_string);
},
remove: function() {
target.children(settings.trigger).unbind('.more');
target.unbind('.more')
target.children(settings.trigger).remove(); },
add_elements: function(data) {
var root = target
var counter = ;
if (data) {
$(data).each(function() {
counter++
var t = template
$.each(this, function(key, value) {
if (t.find('.' + key)) t.find('.' + key).html(value);
})
if (settings.scroll == 'true') {
root.children('.loading').before(t.html())
} else {
root.children(settings.trigger).before(t.html())
}
root.children(settings.template + ':last').attr('id', 'more_element_' + ((variables.last++) + ));
}) } else methods.remove()
// target.children('.loading').css('display', 'none');
if (counter < settings.amount){
methods.remove();
target.children('.loading').html("已经到底了");
}
},
get_data: function() {
var ile;
lock = true;
target.children(".loading").css('display', 'block');
$(settings.trigger).css('display', 'none');
if (typeof(arguments[]) == 'number') {
ile = arguments[];
} else {
ile = settings.amount;
}
if(variables.last >= cur_last) {
var postdata = settings.data;
postdata['last'] = variables.last;
postdata['amount'] = ile;
$.post(settings.address, postdata, function(data){
$(settings.trigger).css('display', 'block')
methods.add_elements(data)
lock = false;
}, settings.format);
cur_last = cur_last + ;
}
}
};
$.fn.more = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, ));
} else if (typeof method == 'object' || !method) {
return methods.init.apply(this, arguments);
} else $.error('Method ' + method + ' does not exist!');
}
$(document).ready(function() {
$(window).on('scroll', function() {
if ($(document).scrollTop() + $(window).height() > $(document).height() - ) {
$('.get_more').click();
}
});
});
})(jQuery)

使用jquery.more.js上滑加载更多的更多相关文章

  1. vue 上滑加载更多

    移动端网页的上滑加载更多,其实就是滑动+分页的实现. <template> <div> <p class="footer-text">--{{f ...

  2. Android如何定制一个下拉刷新,上滑加载更多的容器

    前言 下拉刷新和上滑加载更多,是一种比较常用的列表数据交互方式. android提供了原生的下拉刷新容器 SwipeRefreshLayout,可惜样式不能定制. 于是打算自己实现一个专用的.但是下拉 ...

  3. dropload.js 上滑加载,下拉刷新

    https://github.com/ximan/dropload dropload a javascript implementation of pull to refresh and up to ...

  4. Android的ListView分页功能(上滑加载更多)

    今天主要工作是将之前实现的各种ListView显示全部信息,优化成了每次加载几条数据,然后上滑的时候加载更多,底部显示一个进度条和一个文字提示,然后加载完毕后,将提示信息隐藏. 一边看教学视频一遍敲代 ...

  5. 移动端web页面上滑加载更多功能

    背景介绍: 开发企业微信的一个应用,实现在企业微信中调用自己程序页面,页面加载多模块数据,向下滑加载更多,等等等等,一波三折 然后很早就成功了是这样实现的: html: <div id=&quo ...

  6. jquery 上滑加载更多

    $(document).ready(function() { var totalPage = {$totalPage};//总页数 var page = {$page}; //起始页 var page ...

  7. APICloud 上滑加载更多

    <!DOCTYPE html><html>        <head>        <meta charset="UTF-8">  ...

  8. 微信小程序上滑加载更多

    onReachBottom: function () { var that = this var limit = that.data.limit var count = that.data.count ...

  9. jq上滑加载更多

    html 结构 <div id="main"> <ul class="order-list" id="list_box"& ...

随机推荐

  1. 记录一段QQ关于 UNIGUI 的Session 时间设定

    记录一段QQ关于 UNIGUI 的Session 时间设定,来自[台中]cmj(31365722):  [重點說明] 1.UniGUI的Session就是UniMainModule.   2.Sess ...

  2. 华为交换机配置NTP服务端/客户端

    作者:邓聪聪 配置设备作为NTP服务器 单播客户端/服务器模式 # 配置NTP主时钟,层数为2. <HUAWEI> system-view [HUAWEI] ntp refclock-ma ...

  3. 用UDP实现聊天功能

    // SK003Dlg.cpp : implementation file //   #include "stdafx.h" #include "SK003.h" ...

  4. v-on 绑定自定义事件

    每个 Vue 实例都实现了事件接口,即: 使用 $on(eventName) 监听事件 使用 $emit(eventName) 触发事件 Vue 的事件系统与浏览器的 EventTarget API  ...

  5. 使用python找出nginx访问日志中访问次数最多的10个ip排序生成网页

    使用python找出nginx访问日志中访问次数最多的10个ip排序生成网页 方法1:linux下使用awk命令 # cat access1.log | awk '{print $1" &q ...

  6. OpenStack实践系列③镜像服务Glance

    OpenStack实践系列③镜像服务Glance 3.5 Glance部署 修改glance-api和glance-registry的配置文件,同步数据库 [root@node1 ~]# vim /e ...

  7. Linux 文档与目录结构

    Linux之文档与目录结构   Linux文件系统结构 Linux目录结构的组织形式和Windows有很大的不同.首先Linux没有“盘(C盘.D盘.E盘)”的概念.已经建立文件系统的硬盘分区被挂载到 ...

  8. sql拼接显示table的多个列

    SELECT DeptName AS text,CONVERT(VARCHAR(10),ID)+','+DeptCode+','+ISNULL(Remark,'') AS tags,'' AS hre ...

  9. npm i 和 npm install 的区别

    实际使用的区别点主要如下(windows下): 1. 用npm i安装的模块无法用npm uninstall删除,用npm uninstall i才卸载掉 2. npm i会帮助检测与当前node版本 ...

  10. LuoGu P2420 让我们异或吧

    其实......这就是个SB题,本来看到这个题,和树上路径有关 于是--我就欣喜地打了一个树剖上去,结果嘞,异或两遍等于没异或 所以这题和LCA屁关系都没有,所以这题就是个树上DFS!!!! 所以它为 ...