Retired-AJAX, retired-AJAX. Retired: retired-AJAX, retired-AJAXhi played basketball last night. You know, the last time I spent my foot was four years ago. The last time I hurt my foot was my left foot. I also retired from basketball for so many years.-AJAX, retirement-AJAX
Hi
The tragedy of playing the game last night broke my foot.
You know, the last time I put my foot on my feet was four years ago, the last time I hurt my left foot was the most serious one of my many years of basketball career. After a full month of rest, I was taken care of by the dormitory brothers and finally bought a noble ankle guard to make a comeback.
Later, when I played the ball, my left foot was usually with an ankle guard, and the usual small scales had almost no impact. Four years later, it was a good day last night. Unfortunately, this injury is caused by the right foot, and the situation is the same.
However, when you get hurt, you also have time to think about things that you don't have to touch in an impetuous manner. The blessings depend on each other, and php learning cannot be stopped.
1,AJAX
II,AJAXConcepts
2.2 XMLHttpRequestObject creation
AbbreviatedXHR.
The first thing is to instantiate an XHR object.
Var request = new XMLHttpRequest ();
Versions earlier than IE6 are not supported. Other versions are supported.
2.3 HttpRequest
The computer communicates over the network.A rule.
Is a stateless protocol.--Do not establish persistent connections. (No Memory)
Step: TCP connection, request, response, send data, and close the connection.
--Request
Basic format: method and action (GET or POST) + URL + header (verification information) + body
GET: Used to obtain information., Use URL to pass parameters (so there are restrictions on characters ),Is the defaultHttpMETHOD. it is generally safe.-- Because GET only obtains information, it is equivalent to a query and does not change data. however, GETVisible to all.
POST: Used to modify resources on the server.(For example, sending form data );Invisible to others, Do not use URL, there is no limit on the number of sent messages.
GET is idempotent (there will be no difference in the number of operations ).
--Response
Basic format: Status Code (number and text) + response header + response body
-Status Code: Starts with a three-digit number,The first number defines the status code type.:
1xxIndicates the information class, which is being processed;
2xxSuccess;
3xxRedirection. the request failed;
4xxIndicates a Client Error. the request submitted by the client is incorrect. for example, 404 not found indicates that the document referenced in the request does not exist;
5xxIndicates a server error, which is a headache, for example, 500.
2.4 XHRSend request
There are two useful methods.
Establish a connection: request. open (method, url, async) -- method: GET and POST, url address, synchronous or asynchronous (asynchronous is true)
Send request: request. send (string) -- each connection should be open, so the send here can not write method, url
2.5 XHR get/get response
Use the following methods or attributesObtainCorresponding data:
ResponseText: Get response data in string format
ResponseXML: XML format
Status and statusText: return the HTTP status code in numbers and text format
GetAllResponseHeader (): obtains all response headers.
GetResponseHeader (): query the value of a field in the response
Determine whether to respond
ReadyState property -- 01234, to 4 is the completion of the response. You can use the following programs to listen and judge.
Request. onreadystatechange = function (){
If (request. readyState ===4 & request. status === 200 ){
Request. responseText
}
}
--General steps
New XHR objects + open method + send data + listen on the process.
III,AJAXSimple example
3.1Introduction
Complete: query the employee information. enter the employee ID to query the basic information of the employee + the information of the new employee, including the employee name, number, gender, and position;
Implementation: pure html page + PHP page, used to query the background interface of employees and new employees;
3.2 server implementation
Here I use the wamp collection end, and many things do not need to be changed.
Then write the program in dreamwaver
-------------------------
Ah, the will is not strong enough... If you do not want to write it today, you must finish it tomorrow!
Cutting hi kicked his foot in the tragedy of playing the game last night. You know, the last time I reached my foot was four years ago, the last time I hurt my left foot, I played basketball for so many years...