var sv_defaultArray = new Array([]);
sv_defaultArray[0] = "post 1";
sv_defaultArray[1] = "post 2";
sv_defaultArray[2] = "post 3";
Console states the array here is [“post 1”, “post 2”, “post 3”];
var myJsonString = JSON.stringify(sv_defaultArray);
Console states the array here is [“post 1”, “post 2”, “post 3”];
$.post("http://www.foobar.com/write.php", { 'array': myJsonString });
Array is posted as: [\”post 1\”,\”post 2\”,\”post 3\”]
What is going wrong, why is the data not getting converted to json and submitted as json too?
When i call the databack i am calling it as jsonp wrapped in a callback function
You have forgot to set
dataTypeon$.postAnyway, you have plain Array, so it will be decoded the same way. If you need
{}you have to encode associative array or object.