AJAX 中的 GET 还是 POST? [英] GET vs POST in AJAX?

查看:34
本文介绍了AJAX 中的 GET 还是 POST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 AJAX 中有 GET 和 POST 请求,因为它无论如何都不会影响页面 URL?由于数据没有反映到页面 URL,因此通过在 AJAX 中通过 GET 传递敏感数据有什么区别?

Why are there GET and POST requests in AJAX as it does not affect page URL anyway? What difference does it make by passing sensitive data over GET in AJAX as the data is not getting reflected to page URL?

推荐答案

您应该根据您对 Web 服务的要求使用正确的 HTTP 动词.

You should use the proper HTTP verb according to what you require from your web service.

处理集合 URI 时,例如:http://example.com/resources/

When dealing with a Collection URI like: http://example.com/resources/

GET:列出集合的成员,并附上他们的成员 URI,以便进一步导航.例如,列出所有待售汽车.

GET: List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale.

PUT:含义定义为用另一个集合替换整个集合".

PUT: Meaning defined as "replace the entire collection with another collection".

POST:在集合中创建一个新条目,其中 ID 由集合自动分配.创建的 ID 通常包含在此操作返回的数据中.

POST: Create a new entry in the collection where the ID is assigned automatically by the collection. The ID created is usually included as part of the data returned by this operation.

DELETE:含义定义为删除整个集合".

DELETE: Meaning defined as "delete the entire collection".

处理 Member URI 时,例如:http://example.com/resources/7HOU57Y

When dealing with a Member URI like: http://example.com/resources/7HOU57Y

GET:检索以适当 MIME 类型表示的集合中寻址成员的表示.

GET: Retrieve a representation of the addressed member of the collection expressed in an appropriate MIME type.

PUT:更新集合的寻址成员或使用指定的 ID 创建它.

PUT: Update the addressed member of the collection or create it with the specified ID.

POST:将被寻址的成员本身视为一个集合,并为其创建一个新的下级.

POST: Treats the addressed member as a collection in its own right and creates a new subordinate of it.

DELETE:删除集合的寻址成员.

DELETE: Delete the addressed member of the collection.

来源:维基百科

这篇关于AJAX 中的 GET 还是 POST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆