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