为什么不总是使用HTTP发布进行Ajax调用?

编程入门 行业动态 更新时间:2024-10-26 09:25:41
本文介绍了为什么不总是使用HTTP发布进行Ajax调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道HTTP get和post方法之间的区别(如这个问题). 我的问题是,为什么不总是对AJAX调用使用post方法,这是安全的.有更快的获取请求吗?有理由更喜欢先发表然后发表?

I know the differences between HTTP get and post methods (as expalined in big details in this question). My question is why not always use the post method for AJAX calls, which is safe. Is there get request faster? is there is reason to prefer get then post?

对于没有ajax调用,有一个原因-共享指向相同URL的链接,但是对于AJAX,此参数不好...

For none ajax call there is a reason - to share a link to the same url, but for AJAX this argument it's not good...

推荐答案

GET请求更小,更快;并在客户端以及可能正在使用的任何代理服务器中利用缓存.

GET requests are smaller and faster; and leverage caching, both on the client side and on the part of any proxies that may be in play.

对于那些预计不会经常更改的数据,GET请求通常非常明智,因为除非有必要,否则它们更有可能不被重新发送.

For data that isn't expected to change very often, GET requests are often very sensible, as they have a greater chance of not being resent unless necessary.

但是,对于预期会更频繁更改的数据,POST确实是更安全的选择,因为它将始终重新发送到服务器,并确保始终尊重更改.

For data that is expected to change more often, however, POST is indeed the safer option, as it will always be resent to the server, making sure that changes are always respected.

还有一些语义问题在起作用. POST请求实际上仅应在旨在修改服务器上的数据时使用.

There is also semantic issues that come into play. POST requests should really only be used when the intent is to modify data on the server.

更多推荐

为什么不总是使用HTTP发布进行Ajax调用?

本文发布于:2023-11-23 09:54:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621018.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:HTTP   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!