1 ,get Add the parameter data queue to the submit form ACTION Attribute refers to URL in , The value corresponds to each field in the form one by one , stay URL As you can see in .post It's through HTTP
post mechanism , Place the fields in the form and their contents in the HTML HEADER To the ACTION Attribute refers to URL address . Users don't see the process .

2,get The amount of data transferred is small , Cannot be greater than 2KB.post A large amount of data is transmitted , Generally, it is not limited by default . But in theory , It varies from server to server .

3,<form method="get" action="a.asp?b=b"> With <form method="get" action="a.asp">
It's the same , in other words ,method by get Time action The parameter list at the back of the page is ignored ; and <form method="post"
action="a.asp?b=b"> With <form method="post" action="a.asp"> It's different .

4,get Attention should be paid to caching in requests ,post Please don't worry about it (get The data requested by the browser will be cached , So other people can read this data from the browser's history , Such as account number and password . In some cases ,get This method will bring serious security problems . and post Relatively speaking, these problems can be avoided

use get Attention should be paid to the method :

4.1, cache stay url? A random number is linked behind , time stamp
4.2, Garbled code code encodeURI
about get request , The parameters to be passed must be encodeURIComponent Method treatment , for example :xhr.open(‘get’,‘2.get.php?username
= ‘+encodeURIComponent(leo)+’&age=30&’+new
Date().getTime(),true); Namely get Pass parameters need to be spliced to url among (new Date().getTime() Is the added timestamp ).

use post Attention should be paid to the method :

4.3, Data in send() It is passed as a parameter . example :xhr.send(‘username=leo&age=30’);

4.4, Need to set requestHeader Of content-type by application/x-www-form-urlencoded Declare the type of data sent . example :xhr.setRequestHeader(‘content-type’,‘application/x-www-form-urlencoded’);
therefore post There is no cache problem , No coding is required

5, Using the following example, you can easily see the same data passing through GET and POST To send the difference , The data sent is username= Zhang San .