加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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('

金额:¥' + t.amount + '

'); } else { arrText.push('

优惠:' + t.amount + '

'); } arrText.push('

' + '核销时间:' + t.use_time + '

'); 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('
'); if (t.coupon_type == 1 ) { arrText.push('

金额:¥' + t.amount + '

'); } else { arrText.push('

优惠:' + t.amount + '

'); }; arrText.push('

' + '核销时间:' + t.use_time + '

'); arrText.push('
'); } discount.append(arrText.join('')); $(".load").remove(); } else { $(".load").remove(); discount.append('
'); $(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('

暂无核销记录

') }
  },error: function (data) {

  }

})
$(window).bind("orientationchange",function() {
$('.sliders').css('left',$(window).width() / 2 +'px');
})
})

以上所述就是本文的全部内容了,希望大家能够喜欢。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读