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?
相关问题
- Angular RxJS mergeMap types
- Carriage Return (ASCII chr 13) is missing from tex
- Using :remote => true with hover event
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- C#中 public virtual string Category { get; }这么写会报错:
- spring boot用ajax发送请求后,请求路径多了controller的路径
- 针对复杂结构的前端页面,如何更好地与后台交互实现动态网页?
- 请大神帮忙 post向https接口发送数据 部署到服务器为什么运行一会后就会报空指针
- ajax上传图片,偶尔会出现后台保存的图片有错误或者已损坏,请问可能是什么原因造成的?
- 前端 我想知道怎样通过发ajax请求向服务器拿到数据然后分页显示 最好是点击一页就发一次请求
- WCF发布Windows服务 POST方式报错 GET方式没有问题 应该怎么解决?
Thanks.. I mainly use the GET method with Ajax and I haven't got any problems until now except the following:
Internet Explorer (unlike Firefox and Google Chrome) cache GET calling if using the same GET values.
So, using some interval with Ajax GET can show the same results unless you change URL with irrelevant random number usage for each Ajax GET.
Another difference between
GET
andPOST
is the way caching is handled in browsers.POST
response is never cached.GET
may or may not be cached based on the caching rules specified in your response headers.Two primary reasons for having them:
GET
requests have some pretty restrictive limitations on size;POST
are typically capable of containing much more information.The backend may be expecting
GET
orPOST
, depending on how it's designed. We need the flexibility of doing aGET
if the backend expects one, or aPOST
if that's what it's expecting.It's simply down to respecting the rules of the http protocol.
Get - calls must be idempotent. This means that if you call it multiple times you will get the same result. It is not intended to change the underlying data. You might use this for a search box etc.
Post - calls are NOT idempotent. It is allowed to make a change to the underlying data, so might be used in a create method. If you call it multiple times you will create multiple entries.
When we use the GET method in Ajax, only the content of the value of the field is sent, not the format in which the content is. For example, content in the text area is just added in the URL in case of the GET method (without a new line character). That is not the case in the POST method.
You normally send parameters to the AJAX script, it returns data based on these parameters. It works just like a form that has method="get" or method="post". When using the GET method, the parameters are passed in the query string. When using POST method, the parameters are sent in the post body.
Generally, if your parameters have very few characters and do not contain sensitive information then you send them via GET method. Sensitive data (e.g. password) or long text (e.g. an 8000 character long bio of a person) are better sent via POST method.