Skip to content

Instantly share code, notes, and snippets.

@srph
Created January 18, 2017 05:09
Show Gist options
  • Select an option

  • Save srph/387abd02bc6727bd3bf1021f5d12cb56 to your computer and use it in GitHub Desktop.

Select an option

Save srph/387abd02bc6727bd3bf1021f5d12cb56 to your computer and use it in GitHub Desktop.
jQuery: Transform serialized form data into POJO
/**
* Transform serialized form data to POJO
* @param {jQuery}
* @return {object}
*/
function serialize(form) {
return form.serializeArray().reduce(function(previous, next) {
previous[next.name] = next.value || '';
return previous;
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment