Is it possible to pass inputs data
attibutes values when using jQuery's serialize()
or serializeArray()
?
I don't want to append the data
values to already serialized form (like explained here: jquery form.serialize and other parameters). I need to serialize data
with field name and value at the same time, so I can get object like this:
{
{name: 'field_1', value: 'ABC', id='1'}
{name: 'field_2', value: 'XYZ', id='2'}
}
Example form:
<form name="" method="" action="">
<input type="text"name="field_1" value="ABC" data-id="1">
<input type="text" name="field_2" value="XYZ" data-id="2">
<input type="submit" name="submit" value="Save">
</form>
Is it doable or do I need to create such object manually?