I’m populating an array nodevalues with objects. It looks like this:
nodevalues.push({id: this.id, left: left, right: right});
This line is inside a $.each() iterator which iterates over some li nodes and also calculates the left and right values.
So I have an array with several objects who all look the same:
Is it possible to serialize this array to an url string for database storage using jQuery.post()?
Calling $(nodevalues).serialize() returns nothing and $.param(nodevalues) returns undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined&undefined=undefined…
jQuery.param() might do what you want
It seems that param only works on objects, not arrays.
If you wrap your array in an object it works fine:
http://jsfiddle.net/4NELt/