Skip to content
Advertisement

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?

Advertisement

Answer

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?

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement