This is my code on the client side:
$.ajax({
type:'POST',
charset:'utf-8',
url:'http://localhost:8180/GisProject/MainService',
data:JSON.stringify(params),
success:function(msg)
{
console.log(msg);
},
error:function(xhr,status)
{
console.log(status);
},
contentType:"application/json"
});
I have previously parsed this data in Node using express.bodyParser
but now I have to parse it using the servlet
.I have seen people assign variables here without using JSON.stringify
and getting that variable using request.getParameter(myData)
.
What is the standard way of getting the JSON
data into the servlet
?
And why do people seem to be sending Javascript objects
with JSON embedded as a String within like data:{mydata:JSON.stringify(actualData)}
?
In case I was not being clear,I want to use the doPost
method's request
object to get the data I sent from the client side.