This one is really weird. I've multiple $.post()
in the code but there is one dunno why sends the json parameters as x-www-form-urlencoded
instead and therefore doesn't work.
Here's the code:
$.post("/Route/SaveTransportProperties", { properties: JSON.stringify(propArray), currTravelBox: JSON.stringify(travelBoxObj), accessToken: getAccessToken()}, function(data)
{
//DO STUFF
});
The XHR looks like this in Firefox:
Any ideas why is this happening? I also enforced the type as 'json' but doesn't work either.
you can also force your data to be a json in the success function:
data = JSON.parse(data);
If you want to send the data as json then use the $.ajax function
You can specify type post and dataType json.
Taken from ajax documentation
http://api.jquery.com/jQuery.ajax/
Because $.post() is for sending form-like requests. $.ajax is for sending whatever you want to. See
contentType
in$.ajax
page for more information.Quote:
this also works for me