I have the following setup
On client side I am using a complex Javascript variable something like this
var order = {
name:"",
id:"",
cost:"",
details:{
sItem:[{name:"",cost:""}],
dItem:[{name:"",cost:"", components:[{name:"",quantity:""}]}]
}
}
I have a controller on server in c# like this
public string getCost(string order)
{
var sOrder = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(order);
//do the processing here
return "I am processed";
}
In my Javascript I am calling this as
$.getJSON("Api/menu/getCost/" + JSON.stringify(order),
function (data) {
window.alert('i m here : success');
});
The problem is when I send this request the server responds with bad request, however if I append a simple string like "hello" instead of JSON.stringify(order). The controller receives it and returns with success with no problem, so I know the problem is somewhere in converting the order to JSON but dont know how to find out.
Yes, I am using getJSON and returning a simple string but thats not a problem, as I will be returning a JSON string later on when the processing is done. Actually that will be the same JSON received with some values of the properties changed.