Reputation: 3164
Is there any built-in solution for posting array of objects, through jquery?
The array is
data = [{
id: "333",
date: "22/12/2015"
},
{
id: "333",
date: "22/12/2015"
}]
$.post('url', data, function(){}, "json");
failed
Upvotes: 0
Views: 60
Reputation: 227240
You need to pass values in a POST as key/value pairs. You can't just send the array, you need to give it a "key" in the POST array.
$.post('url', {data: data}, function(){}, "json");
Upvotes: 0
Reputation: 16714
You can send an object that contains the array like this:
data = {
items: [{
id: "333",
date: "22/12/2015"
},
{
id: "333",
date: "22/12/2015"
}]
}
$.post('url', data, function(){}, "json");
Upvotes: 1