Home > Backend Development > PHP Tutorial > PHP Ajax Getting Started HelloWorld_PHP Tutorial

PHP Ajax Getting Started HelloWorld_PHP Tutorial

WBOY
Release: 2016-07-13 10:35:14
Original
866 people have browsed it

A brief discussion of Ajax

 Ajax is the abbreviation of Asynchronous JavaScript and XML (and DHTML, etc.).

It is composed of HTML+JS+DOM. This tutorial does not involve DOM for the time being.

The concept of synchronization: When the page submits the POST form, is the entire page waiting for the server to return (in a blank state) and then refresh? Yes, this is synchronization.

The concept of asynchronous: after the form is submitted, other parts of the page remain as usual.

Ajax is the link between the page and the server. As a piece of JS code, it intercepts the submission information of the page, then processes it and submits it to the server, then listens for the information returned by the server, and then feeds it back to the page.

To use it you need a handle: xmlHttp = new XMLHttpRequest();

We play the role of mistress based on this object.

Refer to the comments below to understand the ajax process:

 1. Generate XMLHttpRequest object

 2. Create the URL to be redirected

 3. Open the server conn

 4. Set the function to be executed after the server completes the operation

 5.send ajax

6. The function to be executed must continue to monitor after the end (the mechanism does not require us to implement it)

Hey, I graduated from Shengmajiagou Men’s Vocational and Technical College and I don’t have much education. The above is my superficial understanding.

For the high-end: Mastering Ajax, Part 1: Introduction to Ajax

Actual operation

Create a new testAjax folder in wamp/www/ with two files in it: index.html and getZipcode.php

index.html

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 Test ajax in <a href="http://www.2cto.com/kf/web/php/" target="_blank" class="keylink">PHP</a>...        
    

City:

    

Zip Code:

     

  getZipcode.php

?

1 2 3 4 5 6 7 8 9 10 11 12 ";     }else{         $city = $_GET["city"];         if($city != null && $city != ""){             echo $city."_010";         }else{             echo "city is null?";         }     } ?>

Actual results:

PHP Ajax 入门HelloWorld   帮客之家

No matter what I enter in City, the zip code below will be added with a "_010", in real time.

Complaint: zipcode means postal code (English is taught by physical education teachers).

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/745029.htmlTechArticleA brief discussion of Ajax Ajax is the abbreviation of Asynchronous JavaScript and XML (and DHTML, etc.). It consists of HTML+JS+DOM. This tutorial does not involve DOM for the time being. The concept of synchronization: the page submits the POST form,...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template