Use of the send method parameters in Ajax

Source: Internet
Author: User

Generally, parameters submitted using Ajax are simple strings. You can directly use the get method to write the parameters to be submitted to the URL parameters of the open method, the parameter of the send method is null.

For example:
VaR url = "login. jsp? User = xxx & Pwd = xxx ";
XMLHttpRequest. Open ("get", URL, true );
Xmlhttprequset. Send (null );

You can also use the send method to pass Parameters. The post method is used to pass parameters using the send method. You need to set the Content-Type header and simulate the http post method to send a form so that the server can know how to process the uploaded content. The parameter submission format is the same as that in the get method. You must call the open method before setting the header information.

For example:
XMLHttpRequest. Open ("Post", "login. jsp", true );
XMLHttpRequest. setrequestheder ("Content-Type", "application/X-WWW-form-urlencoded; charset = UTF-8 ");
XMLHttpRequest. Send ("user =" + username + "& Pwd =" + password );

Note that, depending on the submission method, the two submission methods call the background doget method and dopost method respectively.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/vbs19983/archive/2007/10/09/1816490.aspx

Related Article

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.