When I try passing array of array to server it gives(on server log)
1 => [object, object], 2=> [object, object]
using ajax data: data
data on console.log shows:
[Object {name="abc", place="us"}, Object {name="pqr", place="jp"}]
actual array is as follow:
data.push({name: "abc", place: "us"})
data.push({name: "pqr", place: "jp"})
I would like output as (on server):
Person1 = {name="abc", place="us"}
Person2 = {name="pqr", place="jp"}
I tried jQuery.Serialize it does not work and trying to convert it JSON but failed on client side.(giving output [ ])
I am not sure, where I am going wrong. Can I directly send data array to server?
Thanks
Viral
JavaScript arrays and objects are not the same thing. Arrays have elements with numeric indexes, while objects have properties with string key names.
You probably want something like this:
This creates an object (
data) which has properties “Person1” and “Person2” that are themselves references to objects with “name” and “place” properties.Or, the equivalent of the array push method to add your properties to the object is to do this: