So then I will post my comment as an answer. If you want to transfer the array to the server, you can convert it to JSON (at least that would be the easiest imo way).
Use JSON :
$.ajax({ type: 'post', url: 'www.example.com', data: {paramter: JSON.stringify(MyObject)}, success: function(data) { $('.data').html(data) } });
where parameter is the name of the POST parameter you want to use.
JSON.stringify will give you a string like:
'[{"UserId":"2","UserLevel":"5","FirstName":"Matthew"},{"UserId":"4","UserLevel":"5","FirstName":"Craig"}]'
Getting server side, for example. with PHP and json_decode :
$data = json_decode($_POST['parameter']);
will give you an array of objects:
Array ( [0] => stdClass Object ( [UserId] => 2 [UserLevel] => 5 [FirstName] => Matthew ) [1] => stdClass Object ( [UserId] => 4 [UserLevel] => 5 [FirstName] => Craig ) )
I also suggest renaming MyObject to something meaningful that reflects the contents of the variable. Actually you have an array, not an object (yes, I know that arrays are also objects).
source share