GET vs POST in AJAX?

前端 未结 9 1409
北海茫月
北海茫月 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:20

    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.

提交回复
热议问题