hi
Last night, I unfortunately got a sprained foot while playing basketball.
You know, the last time I sprained my foot was four years ago; the injury was to my left foot. It was also the most serious injury to my sprained foot in so many years of playing basketball. After resting for a whole month, I was able to come back under the meticulous care of my brothers in the dormitory, and finally bought a noble ankle brace.
Later, when I played ball again, I usually wore an ankle brace on my left foot, and the usual small splint had basically no effect. Four years have passed, and last night was the end of the good times. Unfortunately, this time the injury was to the right foot, and the condition was just as serious.
However, after being injured, I also have my own time to think about things that I usually have no time to touch in my impatience. It's a blessing and a curse, you can't stop learning PHP.
1, AJAX
2. AJAXConcept introduction
2.2 XMLHttpRequestObject Creation
The abbreviation ofis XHR.
The first thing is to instantiate the XHR object.
var request=new XMLHttpRequest();
Versions before IE6 are not supported, but others are ok.
2.3 HttpRequest
is a rule for computers to communicate over a network.
is a stateless protocol - does not establish a persistent connection. (No memory)
Steps: TCP connection, request, response, send data, close connection.
--Request
Basic format: method and action (GET or POST) URL header (verification information) body
GET: Generally used to obtain information , using URL to pass parameters (so characters are limited), is the default Http method; generally safe - because GET only obtains information, which is equivalent to querying, and does not change the data; but GET is visible to everyone.
POST: Generally used to modify resources on the server (such as sending form data); is not visible to others , does not use URL, and is useful for sending Unlimited quantity.
GET is idempotent (no matter how many times the operation is performed, it will not make a difference).
--Response
Basic format: status code (numbers and text) response header response body
-Status code : starts with three digits, where the first digit defines the type of status code :
1xx indicates information type and is being processed;
2xx means success;
3xx indicates redirection and the request was unsuccessful;
4xx, indicating a client error. The request submitted by the client is incorrect, such as 404 not found, indicating that the document referenced in the request does not exist;
5xx, indicating a server error, which is a very troublesome situation, such as 500.
2.4 XHRSend request
Two useful methods.
Establish a connection: request.open(method, url, async) - method: GET and POST, url address, synchronous or asynchronous (async is true)
Send a request: request.send(string) - each connection should be open, so the send here does not need to write a method, url
2.5 XHR Get/Get Response
Use the following methods or attributes to obtain corresponding data:
responseText: Get response data in string form
responseXML: XML form
status and statusText: Return the HTTP status code in numeric and text form
getAllResponseHeader(): Get all response headers
getResponseHeader(): Query the value of a field in the response
Determine whether to respond
readyState attribute - 01234, to 4 means the response is completed. Use the following program to monitor and judge.
request.onreadystatechange=function(){
if(request.readyState===4&&request.status===200){
request.responseText
}
}
--General steps
new XHR object open method send data to monitor the process.
3. A simple example of AJAX
3.1 Introduction
Complete: Query employee information, query the employee's basic information by entering the employee number. Create new employee information, including employee name, number, gender, position;
Implementation: pure html page PHP page, used to implement the backend interface for querying employees and creating new employees;
3.2 Server-side implementation
I am using the wamp collection end here, so many things do not need to be changed.
Then write the program in dreamwaver
-------------------------
Hey, my will is still not strong enough. . . I won’t write today, I have to finish this tomorrow and worry about the rest!