JQuery + AJAX implementation without refreshing drop-down to load more _ jquery

Source: Internet
Author: User
This article mainly introduces jQuery + AJAX to achieve no-refreshing drop-down loading more relevant information. If you need more information, refer to the development of the Internet era, the web Front-end has been linked to background data, as a web Front-end, it is not just to cut the graph and write html. css interacts with simple js.

Js code

$ (Function () {var page = 1; var discount = $ ('# discount'); var innerHeight = window. innerHeight; var timer2 = null; $. ajax ({url: '/lightapp/marketing/verify/apply/list? Page = 1', type: 'get', ype: 'json', timeout: '000000', cache: 'false', success: function (data) {if (data. error_code = 0) {var arrText = []; for (var I = 0, t; t = data. list [I ++];) {arrText. push ('

'); ArrText. push (''+ t. title +''); if (t. coupon_type = 1) {arrText. push ('

Amount: ¥' + t. amount +'

');} Else {arrText. push ('

Discount: '+ t. amount +'

');} ArrText. push ('

User: Is the s account's primary account? Ah, 12' + t. user_name + ''+ 'verification time: '+ 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 returns wheight = innerHeight; var scrollWhole = Math. max (scrollHeight-scrollTop-Skip wheight); 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, type: 'get', ype: 'json', success: function (data) {if (data. error_code = 0) {var arrText = []; for (var I = 0, t; t = data. list [I ++];) {arrText. push ('

'); ArrText. push (''+ t. title +''); if (t. coupon_type = 1) {arrText. push ('

Amount: ¥' + t. amount +'

');} Else {arrText. push ('

Discount: '+ t. amount +'

') ;}; ArrText. push ('

User: account token 111111111 '+ t. user_name + ''+ 'verification time:' + t. use_time +'

'); ArrText. push ('

');} Discount. append (arrText. join (''); $ (". load "). remove ();} else {$ (". load "). remove (); discount. append ('

No more data.

'); $ (Window ). unbind ('scroll ') ;}; ajax_getting = false ;}}) ;}; $ (". load "). remove () ;}, 200) ;}; if (data. error_code = 156006) {response ('.coupon'0000.html ('

An error occurred!

Cause: not logged on

')}; If (data. error_code = 156003) {response ('.coupon'0000.html ('

An error occurred!

Cause: the permission is insufficient ~ Please add

')}; If (data. error_code = 156007) {response ('.coupon'0000.html ('

An error occurred!

Cause: Service exception

')}; If (data. error_code = 511) {response ('.coupon'0000.html ('

An error occurred!

Cause: the account has not activated the direct account number.

')}; If (data. error_code = 520) {response ('.coupon'0000.html ('

No write-off record

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

The above is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.