Ajax2-php (28), ajax2php28

Source: Internet
Author: User

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;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.