简体   繁体   中英

Is it safe to make a POST request with JSON data using ajax?

I'm working on web application where I need to send some data using ajax with post method. So I have two choices to send data whether in JSON format or query prams. I'm confused which should I use? and is it safe to send data in JSON format?

As @lucasreta mentioned, if you use HTTPS, it doesn't really matter either way.

Both methods are widely used. I know that Google accepts a Post request with query params and responds with a JSON object for ReCaptcha Server side validation .

Sometimes, the decision to use one or the other (or both) is dependent on how easy your chosen back-end technology makes it for you to either parse out query params or serialize JSON.

I will say that there is a general trend in using JSON in the request body as opposed to query params.

I found a couple of SO questions that are more down the lines of what you are asking...

REST API Best practices: args in query string vs in request body

REST API Best practices: Where to put parameters?

Apologies for a lot of edits, my mind was racing. The question is a tad ambiguous.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM