Ajax waterfall flow realizes demo sharing (with code)
This time I will bring you ajax waterfall flow to realize demo sharing (with code). What are the precautions for ajax waterfall flow to realize demo sharing. The following is a practical case, let's take a look.
Recently I heard from friends that there are a lot of waterfalls, so I went to study it myself. I made a simple native demo to share with everyone...Simple It is divided into three documents with detailed comments: img; ajax.php; demo.php
#img folder Input picture 1.jpg; 2.jpg; 3.jpg....
ajax.php page
<?php //模拟从数据库读取数据 $arr = array(); $op = opendir('./img'); //打开目录 //循环读取目录 while (($file = readdir($op)) !== false) { //过滤点和点点 if ($file == '.' || $file == '..') { continue; } $arr[] = $file; } closedir($op); //关闭目录 echo json_encode($arr);
demo.html page
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>瀑布流</title> <style> li{ list-style: none; float: left; margin:4px; } img{ border:4px solid black; } </style> </head> <body> <ul id="ul"> <!-- <li><img src="./img/1.jpg" height="300" alt=""></li> --> </ul> </body> <script> //找对象 var ul = document.getElementById('ul'); //拿数据 function getData() { var ajax = new XMLHttpRequest(); ajax.open('get', 'ajax.php', true); ajax.send(); ajax.onreadystatechange = function() { if (ajax.readyState == 4 && ajax.status == 200) { var res = ajax.responseText; //处理结果 var obj = JSON.parse(res); for (var k in obj) { // obj[k]; //创建节点 var li = document.createElement('li'); li.innerHTML = '<img src="./img/'+obj[k]+'" height="300" />'; ul.appendChild(li); } } } } getData(); var timer; //判断滚动条的高度,加载第二批文件 window.onscroll = function() { //获取三高 var zGao = document.documentElement.scrollHeight;//总高度 var lGao = document.documentElement.clientHeight;//浏览器可用高度 var gGao = document.body.scrollTop || document.documentElement.scrollTop;//滚出去的高度 // console.log(zGao, lGao, gGao); document.title = zGao + '_' + lGao + '_' + gGao; if (zGao - lGao - gGao < 500) { clearTimeout(timer); //用一次性定时器解决连续加载的问题 timer = setTimeout(function(){ getData(); }, 200) } } </script> </html>
How to configure Google Chrome to support AJAX requests of the file protocol
How to use php to receive ajax submissions Data to the background
The above is the detailed content of Ajax waterfall flow realizes demo sharing (with code). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Quark Netdisk and Baidu Netdisk are very convenient storage tools. Many users are asking whether these two softwares are interoperable? How to share Quark Netdisk to Baidu Netdisk? Let this site introduce to users in detail how to save Quark network disk files to Baidu network disk. How to save files from Quark Network Disk to Baidu Network Disk Method 1. If you want to know how to transfer files from Quark Network Disk to Baidu Network Disk, first download the files that need to be saved on Quark Network Disk, and then open the Baidu Network Disk client. , select the folder where the compressed file is to be saved, and double-click to open the folder. 2. After opening the folder, click "Upload" in the upper left corner of the window. 3. Find the compressed file that needs to be uploaded on your computer and click to select it.

The word demo is no longer unfamiliar to friends who like to sing, but many users who have never been exposed to it are curious about what demo means. Now let’s take a look at the meaning of the demo brought by the editor. What does demo mean? Answer: Demo tape. 1. The pronunciation of demo is ['deməʊ] in English and ['demoʊ] in America. 2. Demo is the abbreviation of "demonstration", which generally refers to the preliminary effect of listening to a song before it is officially recorded. 3. Demo is used as a noun to refer to sample tapes and sample records. The meaning of verb is trial (especially software), demonstration and demonstration;

1. First, we enter NetEase Cloud Music, and then click on the software homepage interface to enter the song playback interface. 2. Then in the song playback interface, find the sharing function button in the upper right corner, as shown in the red box in the figure below, click to select the sharing channel; in the sharing channel, click the "Share to" option at the bottom, and then select the first "WeChat Moments" allows you to share content to WeChat Moments.

Recently, Baidu Netdisk Android client has ushered in a new version 8.0.0. This version not only brings many changes, but also adds many practical functions. Among them, the most eye-catching is the enhancement of the folder sharing function. Now, users can easily invite friends to join and share important files in work and life, achieving more convenient collaboration and sharing. So how do you share the files you need to share with your friends? Below, the editor of this site will give you a detailed introduction. I hope it can help you! 1) Open Baidu Cloud APP, first click to select the relevant folder on the homepage, and then click the [...] icon in the upper right corner of the interface; (as shown below) 2) Then click [+] in the "Shared Members" column 】, and finally check all

Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

Mango TV has various types of movies, TV series, variety shows and other resources, and users can freely choose to watch them. Mango TV members can not only watch all VIP dramas, but also set the highest definition picture quality to help users watch dramas happily. Below, the editor will bring you some free Mango TV membership accounts for users to use, hurry up and take a look Take a look. Mango TV latest member account free sharing 2023: Note: These are the latest member accounts collected, you can log in directly and use them, do not change the password at will. Account number: 13842025699 Password: qds373 Account number: 15804882888 Password: evr6982 Account number: 13330925667 Password: jgqae Account number: 1703
