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 |
|
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:
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).