Home  >  Article  >  Backend Development  >  ajax2—php(28)

ajax2—php(28)

WBOY
WBOYOriginal
2016-08-08 09:24:15850browse

Eight 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?

Different sizes of data transferred:

Get: 2k

Post: Original limit

Different ways of transferring data:

Get: Behind the url

Post: After a blank line

Different formats of data transferred:

Get: text string

Post: text string, binary

Get request:

Post request:

1) The parameter positions are different

2) There are more Post requests A content-type request header

Php code:

The packet capture results are as follows:

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

1) post Request

2) Use the content-type request header

3) Put the parameters after the blank line

Make some modifications to the php code in the above question and find 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 For data, you need to use xml or json technology

The corresponding parsing code:

l var xml=xmlHttp.responseXML;

l node=xml.getElementByTagName("TagName");

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

The above has introduced ajax2-php (28), including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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