Reputation: 12475
i have an array like this
places = new Array();
places.push({name: "ci", loc: "bo"})
places.push({name: "ae", loc: "ea"})
if i try to send this data to server with this:
jQuery.ajax({type: "POST", url: "import",
data: { "places[]": places, kind: "pub" },
});
doesn't work. i receive an array of javascript objects
how can i do?
thanks
Upvotes: 3
Views: 2530
Reputation: 816790
You could convert the array to a JSON string:
jQuery.ajax({type: "POST",
url: "import",
data: {places: JSON.stringify(places), kind: "pub" }
});
and on the server side, decode the string. If you use PHP, it would be json_decode
:
$places = json_decode($_POST['places'], true);
Upvotes: 2