1, get is to add the parameter data queue to the submission form the Action property refers to the URL, the value and the form within the field one by one corresponding to the URL can be seen. Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. The user does not see the process.
2, for Get mode, the server side uses Request.QueryString to get the value of the variable, for the Post method, the server side uses Request.Form to obtain the data submitted. The parameters of both methods can be obtained by using request.
3, get the amount of data transmitted less than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the server varies.
4, get security is very low, post security is high.
5, <form method= "get" action= "A.asp?b=b" > <form method= "Get" action= "a.asp" > is the same, that is to say, The parameter list behind the action page is ignored when method is get, while <form method= "post" action= "A.asp?b=b" > <form method= "POST" action= " A.asp "> is not the same.
Other than that
A GET request has the following characteristics: It adds data to the URL, which is passed to the server in this way, usually using a question mark? Represents the end of the URL address and the beginning of the data parameter, followed by a parameter each data parameter in the form of "name = value", the parameters and parameters are separated by a connector &.
The POST request has the following characteristics: The data is placed in the HTTP body, its organization is not only one, there is a & connection, there is a delimiter way, can hide parameters, transfer large numbers of data, more convenient.
With the above instructions, we now have a general understanding of when to use the Get post, right? When we submit a form we usually use post, when we want to transfer a larger data file, we need to use post. When the value passed is only used in the parameter mode (this value is not more than 2KB), you can use the Get method.
Now let's look at the difference between the Get mode and the Post method when sending a request through a URL. The following example makes it easy to see the difference between the same data sent by Get and post, and the data sent is Username= Zhang San:
GET mode, browser type http://localhost?username= Zhang San
GET/?username=%e5%bc%a0%e4%b8%89http/1.1
Accept:image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, Application/vnd.ms-powerpoint, application/vnd.ms-excel , Application/msword, */*
Accept-language:zh-cn
Accept-encoding:gzip, deflate
user-agent:mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;. NET CLR 1.1.4322)
Host:localhost
Connection:keep-alive
POST mode:
post/http/1.1
Accept:image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, Application/vnd.ms-powerpoint, application/vnd.ms-excel , Application/msword, */*
Accept-language:zh-cn
content-type:application/x-www-form-urlencoded
Accept-encoding:gzip, deflate
user-agent:mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;. NET CLR 1.1.4322)
Host:localhost
Content-length:28
Connection:keep-alive
username=%e5%bc%a0%e4%b8%89
The difference is that a URL request comes with a form parameter and a value, one in the message entity of the HTTP request.
Comparing the two paragraphs above, we find that the Get method puts the contents of the form in the previous request header, while Post puts the contents in the body of the request, and the Content-type header of the request is set to Application/x-www-form-ur in the post. Lencoded. The text sent is the same, so you can construct a form submission body:
encodeURIComponent (arg1) =encodeuricomponent (value1) &encodeuricomponent (arg2) =encodeuricomponent (value2) &
Note: encodeURIComponent returns a new String object (Unicode format) that contains charstring content, and all spaces, punctuation, accents, and other non-ASCII characters are replaced with%XX encoding, where XX equals the Hexadecimal number. For example, a space returns "%20". Characters with a value greater than 255 are stored in%UXXXX format. See JavaScript's encodeURIComponent () method.
After understanding the above content, we now use the Ajax XMLHttpRequest object to send some data to the server using Get and post respectively.
GET mode
var postcontent = "Name=" + encodeuricomponent ("Xiaocheng") + "&email=" + encodeuricomponent ("[email protected]");
Xmlhttp.open ("GET", "somepage" + "?" + Postcontent, True);
Xmlhttp.send (NULL);
POST mode
var postcontent = "Name=" + encodeuricomponent ("Xiaocheng") + "&email=" + encodeuricomponent ("[email protected]");
Xmlhttp.open ("POST", "Somepage", true);
Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Xmlhttp.setrequestheader ("Content-type", "Text/xml"); If you are sending an XML file
Xmlhttp.send (postcontent);
Turn: The similarities and differences between get and post two request methods in Ajax