GET vs POST in AJAX?

前端 未结 9 1377
北海茫月
北海茫月 2020-12-01 03:39

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

相关标签:
9条回答
  • 2020-12-01 04:32

    Another difference between GET and POST 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.

    0 讨论(0)
  • 2020-12-01 04:41

    Well, as for GET, you still have the url length limitation. Other than that, it is quite conceivable that the server treats POST and GET requests differently; thus the need to be able to specify what request you're doing.

    0 讨论(0)
  • 2020-12-01 04:42

    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.

    0 讨论(0)
提交回复
热议问题