2017-01-19 16:59:08
<script src="http://zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/dist/dropload.min.js"></script>
<script src="http://zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/dist/dropload.js"></script>
//zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/examples/load-bottom.html
//zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/examples/load-top-bottom.html
//zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/examples/multiple-load.html
//zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/examples/product-list.html
//zhcdn01.xoyo.com/xassets/com/pf/slideloadpage/examples/tab.html
$(function(){
// 页数
var page = 0;
// 每页展示5个
var size = 5;
// dropload
$('.content').dropload({
scrollArea : window,
loadDownFn : function(me){
page++;
// 拼接HTML
var result = '';
$.ajax({
type: 'GET',
url: 'http://ons.me/tools/dropload/json.php?page='+page+'size='+size,
dataType: 'json',
success: function(data){
var arrLen = data.length;
if(arrLen > 0){
}else{ // 如果没有数据
// 锁定
me.lock();
// 无数据
me.noData();
}
// 为了测试,延迟1秒加载
setTimeout(function(){
// 插入数据到页面,放到最后面
$('.lists').append(result);
// 每次数据插入,必须重置
me.resetload();
},1000);
},
error: function(xhr, type){
alert('Ajax error!');
// 即使加载出错,也得重置
me.resetload();
}
});
}
});
});