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. python打印朱莉娅集合

    # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt # 複素数列の計算回数を出力する関数loopmax ...

  2. Windows PowerShell 入門(3)-スクリプト編

    これまでの記事 Windows PowerShell 入門(1)-基本操作編 Windows PowerShell 入門(2)-基本操作編 2 対象読者 Windows PowerShellでコマンド ...

  3. 左侧滚动条js

    <script> var left = document.getElementById('main-left'); var right = document.getElementById( ...

  4. bigfile tablespace

    背景       这次终于有个linux实际迁移oracle的机会了,之前都是学习实验.想起最早时,都是windows搞oracle,又让我想起多年期一个项目,数据量太大及计算逻辑太复杂,我用存储过程 ...

  5. inux下配置rsyncd服务

    创建配置文件 touch /etc/rsyncd/rsyncd.conf #主配置文件 touch /etc/rsyncd/rsyncd.secrets #用户名密码文件,一组用户一行,用户名和密码使 ...

  6. __new__方法和pop方法(判断)

    new方法(构造方法)是在函数一加载的时候就被执行,在init方法执行之前被执行 def __new__(cls,*args,**kwargs): if kwargs.pop('many',False ...

  7. js获取参数函数

  8. Modbus库开发笔记之三:Modbus TCP Server开发

    在完成了前面的工作后,我们就可以实现有针对性的应用了,首先我们来实现Modbus TCP的服务器端应用.当然我们不是做具体的应用,而是对Modbus TCP的服务器端应用进行封装以供有需要时调用. 这 ...

  9. centos7 nginx图片 服务器可以访问ftp用户上传的图片资源的配置

    注:本文参考了csdn:JAVA_DIRECTION的<nginx和ftp搭建图片服务器>一文.在实践中其文在centos7中还是存在缺陷性的 一:前提条件:是成功的安装好了ftp服务器和 ...

  10. SELinux简介(转载)

    几乎可以肯定每个人都听说过 SELinux (更准确的说,尝试关闭过),甚至某些过往的经验让您对 SELinux 产生了偏见.不过随着日益增长的 0-day 安全漏洞,或许现在是时候去了解下这个在 L ...