jQuery+AJAX实现无刷新下拉加载更多
发布时间:2020-12-15 23:31:43 所属栏目:百科 来源:网络整理
导读:随着互联网时代的发展,web前端已经和后台数据挂钩,作为web前端仅仅不是只切图写写html,css 和简单js交互。 js code ' + t.title + ' '); if (t.coupon_type == 1 ) { arrText.push(' 金额:¥' + t.amount + ' '); } else { arrText.push(' 优惠:' + t.a
随着互联网时代的发展,web前端已经和后台数据挂钩,作为web前端仅仅不是只切图写写html,css 和简单js交互。 js code ' + t.title + '');
if (t.coupon_type == 1 ) {
arrText.push(' ');
}
discount.html(arrText.join(''));
};
var ajax_getting = false;
$(window).scroll(function() {
clearTimeout(timer2);
timer2 = setTimeout(function() {
var scrollTop = $(document.body).scrollTop();
var scrollHeight = $('body').height();
var windowHeight = innerHeight;
var scrollWhole = Math.max(scrollHeight - scrollTop - windowHeight);
if (scrollWhole < 100) {
if (ajax_getting) {
return false;
} else {
ajax_getting = true;
}
discount.append('');
$('html,body').scrollTop($(window).height() + $(document).height());
page++;
$.ajax({
url: '/lightapp/marketing/verify/apply/list?page=' + page,success: function (data) {
if (data.error_code === 0) {
var arrText = [];
for (var i = 0,t; t = data.list[i++];) {
arrText.push('金额:¥' + t.amount + ' '); } else { arrText.push('优惠:' + t.amount + ' '); } arrText.push('' + '核销时间:' + t.use_time + ' '); arrText.push('');
if (t.coupon_type == 1 ) {
arrText.push(' ');
}
discount.append(arrText.join(''));
$(".load").remove();
} else {
$(".load").remove();
discount.append('金额:¥' + t.amount + ' '); } else { arrText.push('优惠:' + t.amount + ' '); }; arrText.push('' + '核销时间:' + t.use_time + ' '); arrText.push('');
$(window).unbind('scroll');
};
ajax_getting = false;
}
});
};
$(".load").remove();
},200);
});
if (data.error_code == 156006) {
$('.coupon').html('
出错啦! ')
};
if (data.error_code == 156003) {
$('.coupon').html('原因:未登录 出错啦! ')
};
if (data.error_code == 156007) {
$('.coupon').html('原因:权限不足~请补充 出错啦! ')
};
if (data.error_code == 511) {
$('.coupon').html('原因:服务异常 出错啦! ')
};
if (data.error_code == 520) {
$('.coupon').html('原因:账号未开通直达号 暂无核销记录
}) 以上所述就是本文的全部内容了,希望大家能够喜欢。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |