I am making an AJAX call to a Struts2 Action class via jQuery ajax.
I am sending the json data to the server from my client. If I use "GET" in $.ajax(), the data is transferred to server. If I replace GET with "POST" in $.ajax(),the data is not transferred to server.
My code,
$.ajax(
{
type: 'GET',
url: 'login.action',
contentType: "application/json; charset=utf-8",
dataType: 'json',
data:
{
jsonData: JSON.stringify(
{
number:"10",
name:"ramesh"
})
},
success: function (data)
{
printStudentDetails(data);
}
});
In firebug, while using GET,the json data is visible as
jsonData {"number":"10","name":"ramesh"}
While using POST,the json data is visible as like this,
jsonData=%7B%22number%22%3A34%2C%22name%22%3A34%2C%22
What is the solution to send the data to the server using POST.
JSON.stringify. Firefox won't choke on it, but IE will.