


Example analysis of ajax implementation of three-level linkage writing
Main page code
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="../wenjian/jquery-2.2.3.min.js"></script></head><body><select id="sheng"> <option>请选择</option></select><select id="shi"> <option >请选择</option></select><select id="qu"> <option >请选择</option></select></body></html><script> $.ajax({ data: {parent_id: 0}, //发送的数据 dataType: "json", //返回值的类型 text为string型 type: 'post', //发送请求的方法(get) url: 'sheng_l.php',//发送请求的地址 success: function (data) {//发送成功时的回调函数 // console.log(data); for (var i in data) { $("#sheng").append("<option value='"+ data[i][2] +"'>" + data[i][1] +"</option>") } } }) $(document).ready(function () { $("#sheng").change(function () { $("#shi").get(0).options.length= 1;// $("#qu").get(0).options.length= 1; var data = $("#sheng").find("option:selected").val(); $.ajax({ data:{parent_id:data}, type:"post", dataType:"json", url:"sheng_l.php", success:function (data) { for(var i in data){ $("#shi").append("<option value='" + data[i][2] +"'>" + data[i][1] +"</option>") } } }) }) }) $(document).ready(function () { $("#shi").change(function () { $("#qu").get(0).options.length= 1; var data = $("#shi").find("option:selected").val(); $.ajax({ data:{parent_id:data}, type:"post", dataType:"json", url:"sheng_l.php", success:function (data) { for (var i in data){ $("#qu").append("<option value='" +data[i][2] +"'>" +data[i][1] +"</option>") } } }) }) })
Processing page code
<?php/** * Created by fcc * User: Administrator * Date: 2017/10/29 * Time: 20:56 */require_once "../wenjian/DBDA.class.php";$db = new DBDA(); $sql = "select * from region WHERE father_id = {$_POST['parent_id']}";$result = $db->Query($sql);echo json_encode($result);
The above is the detailed content of Example analysis of ajax implementation of three-level linkage writing. 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

AI Hentai Generator
Generate AI Hentai for free.

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

Journey through the vastness and set foot on the journey to the west! Today, Zhengtu IP officially announced that it will launch a cross-border cooperation with CCTV animation "Journey to the West" to jointly create a cultural feast that combines tradition and innovation! This cooperation not only marks the in-depth cooperation between the two major domestic classic brands, but also demonstrates the unremitting efforts and persistence of the Zhengtu series on the road of promoting Chinese traditional culture. Since its birth, the Zhengtu series has been loved by players for its profound cultural heritage and diversified gameplay. In terms of cultural inheritance, the Zhengtu series has always maintained respect and love for traditional Chinese culture, and skillfully integrated traditional cultural elements into the game, bringing more fun and inspiration to players. The CCTV animation "Journey to the West" is a classic that has accompanied the growth of generations.

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

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

Introduction to the basic writing and usage of Java callback functions: In Java programming, the callback function is a common programming pattern. Through the callback function, a method can be passed as a parameter to another method, thereby achieving indirect call of the method. The use of callback functions is very common in scenarios such as event-driven, asynchronous programming and interface implementation. This article will introduce the basic writing and usage of Java callback functions, and provide specific code examples. 1. Definition of callback function A callback function is a special function that can be used as a parameter

NetEase's "Onmyoji" mobile game announced today that the Onmyoji x Hatsune Miku limited collaboration will officially begin on March 6. The collaboration-limited SSR Hatsune Miku (CV: Saki Fujita) and SSR Kagamine Rin (CV: Asami Shimoda) are coming to Heian Kyo! The linkage online special performance event will officially start in the game on March 9~

Detailed explanation of how to write the less than sign in MyBatis MyBatis is an excellent persistence layer framework that is widely used in Java development. In the process of using MyBatis for database operations, we often use the less than sign (

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make
