Created
January 18, 2017 05:09
-
-
Save srph/387abd02bc6727bd3bf1021f5d12cb56 to your computer and use it in GitHub Desktop.
jQuery: Transform serialized form data into POJO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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