Ajax no flush drop-down loads more.

Source: Internet
Author: User

With the development of the Internet era, the Web front-end has been linked with the background data, as the Web front-end is just not just cut graph write html,css and simple JS interaction.

JS Code

1$(function() {2     varpage = 1;3     varDiscount = $ (' #discount ');4     varInnerheight =Window.innerheight;5     varTimer2 =NULL;6 $.ajax ({7URL: '/lightapp/marketing/verify/apply/list?page=1 ',8Type: ' GET ',9DataType: ' JSON ',TenTimeout: ' 1000 ', OneCache: ' False ', ASuccessfunction(data) { -                 if(Data.error_code = = 0) { -                     varArrtext = []; the                      for(vari = 0, t; t = data.list[i++];) { -Arrtext.push (' <div class= ' consume-whole ' > '); -Arrtext.push (' ); -                         if(T.coupon_type = = 1 ) { +Arrtext.push (' <p> amount: ¥ ' + t.amount + ' </p> '); -}Else { +Arrtext.push (' <p> offer: ' + t.amount + ' </p> '); A                         } atArrtext.push (' <p><span class= ' Hx-user ' > Users: S account whispering Yes Yes Yes ah, ' + t.user_name + ' </span> ' + ' <span> Write-off time: ' + t.use_time + ' </span></p> '); -Arrtext.push (' </div> ')); -                     } -Discount.html (Arrtext.join (")); -                 }; -                 varAjax_getting =false; in$ (window). Scroll (function() { - cleartimeout (timer2); toTimer2 = SetTimeout (function() { +                         varScrollTop =$ (document.body). scrolltop ();  -                         varScrollHeight = $ (' body '). Height ();  the                         varWindowHeight =Innerheight; *                         varScrollwhole = Math.max (Scrollheight-scrolltop-windowheight); $                         if(Scrollwhole < 100) {Panax Notoginseng                             if(ajax_getting) { -                                 return false; the}Else { +Ajax_getting =true; A                             } theDiscount.append (' <div class= "load" ></div> '); +$ (' html,body '). ScrollTop ($ (window). Height () +$ (document). Height ()); -page++; $ $.ajax ({ $URL: '/lightapp/marketing/verify/apply/list?page= ' +page, -Type: ' GET ', -DataType: ' JSON ', theSuccessfunction(data) { -                                     if(Data.error_code = = 0) {Wuyi                                         varArrtext = []; the                                          for(vari = 0, t; t = data.list[i++];) { -Arrtext.push (' <div class= ' consume-whole "><a href="/lightapp/marketing/verify/page/info?rule_id= ' + t.rule _id + ' &coupon_id= ' + t.coupon_id + ' "> '); WuArrtext.push (' ); -                                             if(T.coupon_type = = 1 ) { AboutArrtext.push (' <p> amount: ¥ ' + t.amount + ' </p> '); $}Else { -Arrtext.push (' <p> offer: ' + t.amount + ' </p> '); -                                             }; -Arrtext.push (' <p><span class= ' Hx-user ' > Users: Account sa 111111111 ' + t.user_name + ' </span> ' + ' <span> Write-off time: ' + t.use_time + ' </span></p> '); AArrtext.push (' </a></div> ')); +                                         } theDiscount.append (Arrtext.join (")); -$ (". Load"). Remove (); $}Else { the$ (". Load"). Remove (); theDiscount.append (' <div class= ' no-data ' > No more data. </div> '); the$ (window). Unbind (' scroll '); the                                     }; -Ajax_getting =false; in                                 } the                             });  the                         }; About$ (". Load"). Remove (); the}, 200); the                 }); the                 if(Data.error_code = = 156006) { +$ ('. Coupon '). html (' <div class= "error" >) -                 }; the                 if(Data.error_code = = 156003) {Bayi$ ('. Coupon '). html (' <div class= "error" >) the                 }; the                 if(Data.error_code = = 156007) { -$ ('. Coupon '). html (' <div class= "error" >) -                 }; the                 if(Data.error_code = = 511) { the$ ('. Coupon '). html (' <div class= "error" >) the                 }; the                 if(Data.error_code = = 520) { -$ ('. Coupon '). html (' <div class= "stays" ><span></span><p> no write-off record </p></div> ') the                 } the  the             },94Errorfunction(data) { the  the             } the     })98$ (window). Bind ("Orientationchange",function() { About$ ('. Sliders '). CSS (' left ', $ (window). Width ()/2 + ' px '); -     })101})
View Code

Recommend a front end group: Group name: Html5/css3/js/jq/nodejs/div Group No.: 339840649 Welcome to join in the exchange.

Ajax no flush drop-down loads more.

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.