Skip to content

Instantly share code, notes, and snippets.

@fadomire
Last active December 27, 2015 10:59
Show Gist options
  • Save fadomire/7315744 to your computer and use it in GitHub Desktop.
Save fadomire/7315744 to your computer and use it in GitHub Desktop.
Form to Object
var arr = $('#myForm').serializeArray();
var data = _(arr).reduce(function(acc, field) {
acc[field.name] = field.value;
return acc;
}, {});
@serbanghita
Copy link

For a multi-dimensional form check https://github.com/serbanghita/formToObject.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment