I have the following javascript code:
var data = {message:"Hi"}
var sendJson = function (){
alert(data);
$.ajax({
url:"./jsonTest",
data: data,
contentType:"application/json",
type:"post",
dataType:"json"
}).success(function(reply) {
alert("successful");
});
}
How can I fetch the JSON object on my servlet?
I was previously trying to get it using
request.getParameter("data")
and trying to convert it to a JsonObject, but I kept getting null
.