[jQuery] $.post with an array of variables

[jQuery] $.post with an array of variables


Hi all,
I have an array of variables that is built from the following:
data['freshbox'] = encodeURIComponent(freshBoxType);
data['numitems'] = encodeURIComponent(items.length);
data['customerid'] = customerid;
for (var i=0;i<items.length;i++) {
data['item['+i+'][addonid]'] = encodeURIComponent($
("#itemaddonid"+items[i][0]).val());
data['item['+i+'][itemid]'] = encodeURIComponent(items[i][2]);
data['item['+i+'][qty]'] = encodeURIComponent($("#qtyfield"+items[i]
[0]).val());
data['item['+i+'][freq]'] = encodeURIComponent($("#itemfreq"+items[i]
[0]).val());
}
And what I would like to do is build a set of input variables looking
like below:
data['freshbox'] = 1;
data['numitems'] = 1;
data['customerid'] = 1;
data['item[0][addonid]'] = 456;
data['item[0][itemid]'] = 12;
data['item[0][qty]'] = 1;
data['item[0][freq]'] = 1;
and throw these directly into $.post, such as:
$.post( url, data );
But for some reason the posted variables never make it. Can anyone
help?