Home Backend Development PHP Tutorial 异步加载技术实现当滚动条到最底部的瀑布流效果_PHP

异步加载技术实现当滚动条到最底部的瀑布流效果_PHP

May 31, 2016 pm 07:30 PM
Asynchronous loading Waterfalls flow

异步加载技术实现瀑布流效果。当滚动条到最底部的时候触发一个事件,这个事件写入$.get()事件,向内部程序页传递类别id和页码,程序将会返回那个类别下的相对页的产品列表,如果程序查询当前类无产品即返回空。

滚动条事件要写在window.onscroll中才有效判断。如下:

window.onscroll=function(){<br>    
// var scrolltop=document.documentElement.scrollTop||document.body.scrollTop;
var tops = $(document).scrollTop(); //获取滚动条的位置
var sctop = $(document).height()-$(window).height();
var id = $("#ajax_claid").val();
if(!id){
id=8;
}
$("#ajax_p").val(tops);
if(tops>=sctop)//成立说明滚动条已在最底部
{
var b=$("#ajax_p").val();
if(b>a){
page=page+1;//传递页码
}
var Url = "aja_pro/"+id+"/"+page;//程序页面,查询信息返回数据,直接返回带html的信息。

$.get(Url,function(data){
$("#aja_jia").append(data);
});

}
};
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Exposing Ajax exceptions and a list of ways to resolve errors Exposing Ajax exceptions and a list of ways to resolve errors Jan 30, 2024 am 08:33 AM

The secret of Ajax anomaly is revealed. How to deal with various errors requires specific code examples. In 2019, front-end development has become an important position that cannot be ignored in the Internet industry. As one of the most commonly used technologies in front-end development, Ajax can realize asynchronous page loading and data interaction, and its importance is self-evident. However, various errors and exceptions are often encountered when using Ajax technology. How to deal with these errors is a problem that every front-end developer must face. 1. Network errors When using Ajax to send requests, the most common error is

Effectively deal with situations where jQuery .val() doesn't work Effectively deal with situations where jQuery .val() doesn't work Feb 20, 2024 pm 09:36 PM

Title: Methods and code examples to solve the problem that jQuery.val() does not work. In front-end development, jQuery is often used to operate page elements. Among them, getting or setting the value of a form element is one of the common operations. Usually, we use jQuery's .val() method to operate on form element values. However, sometimes you encounter situations where jQuery.val() does not work, which may cause some problems. This article will introduce how to effectively deal with jQuery.val(

Scrapy asynchronous loading implementation method based on Ajax Scrapy asynchronous loading implementation method based on Ajax Jun 22, 2023 pm 11:09 PM

Scrapy is an open source Python crawler framework that can quickly and efficiently obtain data from websites. However, many websites use Ajax asynchronous loading technology, making it impossible for Scrapy to obtain data directly. This article will introduce the Scrapy implementation method based on Ajax asynchronous loading. 1. Ajax asynchronous loading principle Ajax asynchronous loading: In the traditional page loading method, after the browser sends a request to the server, it must wait for the server to return a response and load the entire page before proceeding to the next step.

Methods and techniques on how to implement waterfall flow layout through pure CSS Methods and techniques on how to implement waterfall flow layout through pure CSS Oct 20, 2023 pm 06:01 PM

Methods and techniques on how to implement waterfall flow layout through pure CSS. Waterfall layout (Waterfall Layout) is a common layout method in web design. It arranges content in multiple columns with inconsistent heights to form an image. Waterfall-like visual effects. This layout is often used in situations where a large amount of content needs to be displayed, such as picture display and product display, and has a good user experience. There are many ways to implement a waterfall layout, and it can be done using JavaScript or CSS.

How to implement waterfall flow in CSS? Two ways to introduce How to implement waterfall flow in CSS? Two ways to introduce Sep 26, 2021 am 10:58 AM

How to implement waterfall flow in CSS? The following article will introduce to you two ways to use CSS to implement waterfall flow. I hope it will be helpful to you!

Detailed explanation of the suspend function in Vue3: Optimizing asynchronous data loading Detailed explanation of the suspend function in Vue3: Optimizing asynchronous data loading Jun 18, 2023 am 08:10 AM

Detailed explanation of the suspend function in Vue3: Optimizing asynchronous data loading In modern websites and applications, asynchronous data loading is essential. However, due to the instability of network connection speeds, asynchronous data loading may cause delays and freezes in the user interface. To solve this problem, Vue3 introduces a new suspend function to optimize asynchronous data loading. The suspense function is a new feature in Vue3. It allows you to display a loading UI when loading data asynchronously until asynchronously.

Detailed explanation of defineAsyncComponent function in Vue3: application of asynchronous loading components Detailed explanation of defineAsyncComponent function in Vue3: application of asynchronous loading components Jun 18, 2023 pm 07:39 PM

Detailed explanation of the defineAsyncComponent function in Vue3: Application of asynchronous loading components In Vue3, we often encounter the need to load components asynchronously. At this time, we can use the defineAsyncComponent function provided by Vue3 to implement the function of loading components asynchronously. This article will introduce in detail the usage and application scenarios of the defineAsyncComponent function in Vue3. 1. defineAsyncComponent

How to read html How to read html Apr 05, 2024 am 08:36 AM

Although HTML itself cannot read files, file reading can be achieved through the following methods: using JavaScript (XMLHttpRequest, fetch()); using server-side languages ​​(PHP, Node.js); using third-party libraries (jQuery.get() , axios, fs-extra).

See all articles