Difference between ajax get and post

1. When using the Get request, the parameters are displayed in the URL, but when using the Post method, they will not be displayed.

2. Use the Get request to send a small amount of data, and the Post request to send a large amount of data

3. Cache, GET access is considered by the browser to be idempotent, that is, there is only one result for the same URL [the same means that the entire URL string matches exactly], so when accessing the second time, if the URL string does not change, The browser directly takes out the result of the first visit (cache).

      POST is considered a variable access (the browser believes that the submission of POST must be changed), to prevent idempotent access of GET, just add ? after the URL +new Date();, [in short, the URL string of each visit is different], this principle should also be followed when designing WEB pages.

 

 

1. Difference between href and Action

href can only get parameters, action can get parameters and post parameters

href is generally used for a single connection, it can take parameters (URL rewriting), it is requested by get, and all parameters can be seen in the address bar;

Action is also used for form submission (such as registration), etc. It can submit a large number of and more complex parameters, which can be submitted through post and get. If you choose the post method, you cannot see the submitted information in the address bar.
To put it simply: connect to an address alone, use href; submit and register information, use action, the default submission method of html form is get , and the get method will cause Chinese garbled characters.

 

The get and post methods in the form correspond to the GET and POST methods in the HTTP protocol respectively during the data transmission process. The main differences between the two are as follows: 
1. Get is used to obtain data from the server, while Post is used to transfer data to the server. 
2. Get adds the data in the form to the URL pointed to by the action in the form of variable=value, and the two are connected by "?", and each variable is connected by "&"; The data is placed in the data body of the form, and is passed to the URL pointed to by the action according to the corresponding method of variables and values. 
3. Get is insecure, because during the transmission process, the data is placed in the requested URL, and many existing servers, proxy servers or user agents will record the request URL in a log file, and then put it in a certain URL. place, so that some private information may be seen by third parties. In addition, the user can also directly see the submitted data on the browser, and some internal system messages will be displayed in front of the user together. All operations of Post are invisible to the user. 
4. The amount of data transmitted by Get is small, mainly due to the limitation of URL length; while Post can transmit a large amount of data, so only Post can be used to upload files (of course, there is another reason, which will be mentioned later). 
5. Get restricts the value of the data set of the Form form to be ASCII characters; while Post supports the entire ISO10646 character set. 
6. Get is the default method of Form.
The quotation marks of the action are filled with the path method, such as sending to the mailbox or other web pages

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326992833&siteId=291194637