码迷,mamicode.com
首页 > 其他好文 > 详细

h5上滑刷新(分页)

时间:2016-03-23 11:24:08      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

$(‘.dom‘).append(‘<div class="loadingwrap" id="loading" style="display:none"><img src="‘ + base + ‘../images/loading.gif"/></div>‘);

$(window).scroll(function(){
if(($(window).scrollTop()+$(window).height() >= $(document).height()-10)){
var url = ‘‘,
totalPage = 4;
pageCount = Loader(url,totalPage,$(‘.dom‘));
}
});

Loader = function(url, totalPage, el) {
var scrollflag = true;

if (scrollflag) {
if (pageCount <= totalPage) {
$(‘#loading,.loadingwrap‘).show();
$.ajax({
type: ‘POST‘,
url: url,
data: {page: pageCount},
dataType: ‘json‘,
beforeSend: function () {
scrollflag = false;
$(‘#loading‘).show();
},
success: function (result) {
el.append(result.data);
pageCount++;
},
error: function (xhr, type) {
},
complete: function () {
scrollflag = true;
$(‘#loading,.loadingwrap‘).hide();
}
});
}
}
return pageCount;
}

h5上滑刷新(分页)

标签:

原文地址:http://www.cnblogs.com/rellame/p/5310262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!