Asynchronous loading technology achieves the waterfall flow from the scroll bar to the bottom

Source: Internet
Author: User
When the scroll bar reaches the bottom, an event is triggered. This event is written to the $. get () event to achieve waterfall flow effect. The asynchronous loading technology of the next interview is used to achieve waterfall flow effect. Trigger an event when the scroll bar reaches the bottom. This event is written to $. the get () event transmits the Category id and page number to the internal program page. the program returns the product list of the relative pages under the category. if the program queries the current class without products, it returns null.

The scroll bar event must be written in window. onscroll to effectively judge the event. As follows:

Window. onscroll = function (){
// Var scrolltop=document.doc umentElement. scrollTop | document. body. scrollTop; var tops = $ (document ). scrollTop (); // obtain the position of the scroll bar var sctop = $ (document ). height ()-$ (window ). height (); var id = $ ("# ajax_claid "). val (); if (! Id) {id = 8 ;}$ ("# ajax_p "). val (tops); if (tops> = sctop) // if it is set up, the scroll bar is already at the bottom {var B = $ ("# ajax_p "). val (); if (B> a) {page = page + 1; // pass the page number} var Url = "aja_pro/" + id + "/" + page; // on the program page, query the returned data and directly return the information with html. $. Get (Url, function (data) {$ ("# aja_jia"). append (data );});}};

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.