Difference between Post and Get

HTTP request type
HTTP (Hypertext Transfer Protocol) is designed to guarantee communication between client and server. The way Http works is a request-response protocol between client and server. The client submits an HTTP request to the server, and the server returns a response to the client. The response contains status information about the request and what may have been requested.
Simply understand, the HTTP protocol is a standard and specification. It is recommended that you use the appropriate type according to your own needs.
There are four main types of HTTP requests: Get, Post, Put, Delete.
Generally speaking, they correspond to the four operations of check, add, change, and delete, but in fact, the four operations can generally be completed through Get and Post. So the most used are Get and Post.


What is the difference between the request methods of Get and Post? The request method of
Get is to append the data to the url to Separate with url and data. The data submitted by Post is placed in the entity data,

xmlHttp.open("get","ajax?name="+ name,true) //get方式
xmlHttp.send(null);



xmlHttp.open("get","ajax,true) //post方式
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xmlHttp.send(name="+ nam);

The main difference between Get and Post
Get is used to get data from the server, and Post is used to pass data to the server.
The temporary understanding of the difference with this is that Get is used to query data from the database, and Post is used to modify data, so Post will pass the information of modifying data to the database.

How secure is Get and Post
? Post is more secure for data transmitted from the client to the service segment, because the data transmitted by get is placed in the requested url, and today there are many servers, proxy servers or user agents that will request The url is logged to a log file and then placed somewhere so it can be easily seen by third parties. In addition, users can also see the submitted data directly on the browser. And all operations of Post are invisible to the user.
But for the database, get is safer, because Get only queries the data and does not make changes to the database; while Post will modify the database.


Finally, there is a newly learned concept in the annex: idempotency.
Idempotent (idempotent, idempotence) is a mathematical and computer science concept commonly used in abstract algebra.
In programming. The characteristic of an idempotent operation is that the impact of any number of executions is the same as the impact of one execution. An idempotent function, or idempotent method, is a function that can be executed repeatedly with the same parameters and achieve the same result. These functions do not affect the system state, and there is no need to worry that repeated execution will cause changes to the system.
The simple understanding of idempotency is that the same url request should return the same result.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325846052&siteId=291194637