Ajax2-php (28), ajax2php28
8. Use post to transmit data
L xmlhttp. open ("post", "action. php ");
L xmlhttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ");
L xmlhttp. send (data );
1. What are the differences between get and post requests?
The size of transferred data is different:
Get: 2 k
Post: original restriction
Different data transmission methods:
Get: After url
Post: After blank rows
Different data transmission formats:
Get: text string
Post: text string, binary
Get request:
Post request:
Php code:
The packet capture result is as follows:
We can see that this http Request
1) post request
2) use the content-type Request Header
3) The parameter is placed behind the blank line.
Modify the php code in the above question and immediately return the latest results.
Post requests do not cause cache problems.
Example:
Use Ajax to input data
9. xml application in ajax
In ajax, we can use responseText for simple returned data.
For large batches of complex data, xml or json technology is required.
Corresponding parsing code:
L var xml = xmlHttp. responseXML;
L node = xml. getElementByTagName ("TagName ");
L node [0]. childNodes [0]. nodeValue;