If you would like to pass a hashmap as a parameter to a POST call in JavaScript, you need to use the dot notation and it will be interpreted as belonging to a hashmap. The code below loops through the properties of an object called ‘options’ and adds each one except for the toString() method to the POST parameter hashmap.
===================================================
Declaration of options variable
var options = {
foo: 'blah',
boo: 'muah',
toString: function() {
return this.foo + ', ' + this.boo;
}
};
===================================================
Inside AJAX call function
if (options != null) {
for (property in options) {
if (property != 'toString')
post_data['options.' + property] = options[property];
}
}
Using this code when you access the POST parameters on the server side, you can reference the ‘options’ POST parameter as a hashmap, i.e. options[‘foo’].