I am trying to post a JSON object to a asp.net webservice.
My json looks like this:
var markers = { \"markers\": [
{ \"position\": \"128.3657142857
markers is not a JSON object. It is a normal JavaScript object.Data to be sent to the server. It is converted to a query string, if not already a string.
If you want to send the data as JSON, you have to encode it first:
data: {markers: JSON.stringify(markers)}
jQuery does not convert objects or arrays to JSON automatically.
But I assume the error message comes from interpreting the response of the service. The text you send back is not JSON. JSON strings have to be enclosed in double quotes. So you'd have to do:
return "\"received markers\"";
I'm not sure if your actual problem is sending or receiving the data.