Ajax1-php (27), ajax1php2
1 Introduction
Working principle of web programs:
Working principle of traditional web programs:
Ii. core objects
XMLHttpRequest
1. Create an object
In different browsers, the method for creating ajax objects is slightly different.
IE:
New ActiveXObject ("Microsoft. XMLHTTP ")
Iii. Ajax object attributes and methods:
1. Related methods:
L open (method, url)
Initialize ajax objects
Method: Request method post, get
Url: Request resource address
L setRequestHeader (header, value)
Set Request Header Information
Header: Header information
Value: Value
L send (content)
Send request
Content: The passed parameter must be placed here only when the post request is made.
2. related attributes:
L readyState
The status code of the Ajax object, which changes at any time
0: indicates that the object has been created but not initialized.
1: indicates that the object has been initialized but not sent
2: The send method has been called for the request.
3: receiving data (receiving part)
4: Received
L onreadystatechange
The callback function triggered when the status code of the ajax object changes.
L status
Http response status code
L statusText
Http response text
L responseText
Http Response content text
L responseXML
Xml data of http Response content
There are three main ways to transmit Ajax object data:
Text: responseText
Xml: reponseXML
Json: responseText