Home >Backend Development >PHP Tutorial >ajax2—php (28), ajax2php28_PHP tutorial

ajax2—php (28), ajax2php28_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:53:22860browse

ajax2—php (28), ajax2php28

8 Use post to transfer 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?

Transfer data size is different:

Get:2k

Post: original limit

Different ways of transmitting data:

Get: behind url

Post: after a blank line

Transfer data formats are different:

Get: text string

Post: text string, binary

Get request:

ajax2—php (28), ajax2php28_PHP tutorialPost request:

ajax2—php (28), ajax2php28_PHP tutorialPhp code:

The packet capture results are as follows:

As you can see from the picture above, this http request

1) Post request

2) Use content-type request header

3) The parameters are placed after the blank line

I made some modifications to the php code in the above question and found that the latest results can be returned immediately.

Post requests will not cause caching issues.

Example question:

Use Ajax to complete data entry

9. Application of xml in ajax

In ajax, for simple returned data, we can use responseText to get the value

For large batches and complex data, xml or json technology needs to be used

Corresponding parsing code:

l var xml=xmlHttp.responseXML;

l node=xml.getElementByTagName(“TagName”);

l node[0].childNodes[0].nodeValue;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1001460.htmlTechArticleajax2—php (28), ajax2php28 8. Use post to transmit data lxmlhttp.open("post",action.php "); lxmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); lxmlht...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn