views:

87

answers:

1

On form submit I want to serialize the form's elements, then stick another field on, then submit with $.post. Can't quite get it. The form's submit action looks like:

data = $(this).serializeArray();
data.push({filter: $.toJSON(filter)});

$.post("/datawarehouse/new.php", data);
return false;

But it's just the form's fields and then undefined/undefined. For the record $.toJSON(filter) works as I've seen the output. Also tried:

data.filter = $.toJSON(filter);

And

data['filter'] = $.toJSON(filter);

Any ideas?

A: 

I think you might have better luck putting a hidden field in your form and on form submit, set the value of the hidden field. Let the jquery serializer handle the serialization.

marcc