javascript - Ajax requests background data through the interface. When to use put, get, and post? Please give advice.
滿天的星座
2017-05-19 10:25:20
ajax requests background data through the interface. Please give advice on when to use put, get, and post.
get Get
post New
put Update
For more information, please Baidu "http verb"
Obviously, you can guess the meaning just by looking at the English words... As mentioned above, post is generally used to submit information, and get gets...
The commonly used methods are get for querying and post for data modification (add, delete, modify)
I think you can clearly distinguish the advantages and disadvantages between the three, and then it depends on the situation. There is no special rule on when to use which one
This depends on whether the RESTful service is used. If not, generally only get and post submissions are required. If you use REST, there will be get, post, put, and delete. get: obtain data operation; post: create data operation; put: update data operation; delete: delete data operation; in fact, there are also head, options, trace, and connect methods; there are eight methods in total
I think what kind of interface is given to you by the backend? It wants to give you an interface for getting parameters. Can you use post to submit? The backend says that this interface is accessed using get, and what are the parameters? Then you just use get access and bring the parameters! What's the use of worrying about it?
get acquisition, only short parameters and can be used in clear text, can be used when there are no restrictions in the background; post parameters are relatively long, or do not require clear text transmission, such as passwords, etc., can be used without restrictions in the background;