Asynchronous loading technology achieves Waterfall Stream effect, asynchronous loading technology waterfall _ PHP Tutorial

Source: Internet
Author: User
Asynchronous loading technology achieves Waterfall Stream effect and asynchronous loading technology waterfall. Asynchronous loading technology achieves Waterfall Stream effect, asynchronous loading technology waterfall asynchronous loading technology achieves Waterfall Stream effect. Trigger an event when the scroll bar reaches the bottom. This event is written to the asynchronous loading technology to achieve Waterfall Stream effect, and asynchronously loaded to the technical waterfall.

Asynchronous loading technology achieves Waterfall Stream 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 );});}};

  


My html page is too long. how can I achieve a waterfall-like effect? Is the remaining part of content loaded when browsing to the bottom?

① Data is divided into two parts, and the rest is placed in a JSON file. if there is less data, it can be placed in js code.
② Implement a four-column layout and create several ul as the initial data display on the page.
③ Determine the distance between the last li and the browser window, and trigger the function to traverse and add the data in JSON to the page in ul format.

How can I load pages asynchronously?

To put it bluntly, there is no need for new technologies.
The jquery library has encapsulated the ajax effect and can be used directly. ajax. post. get. load
For example, a click method

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.