Created
October 12, 2018 13:32
-
-
Save faxemaxee/5e8d66213b416c44e8145f3090455c21 to your computer and use it in GitHub Desktop.
This file contains 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
function getFormData($form) { | |
var unindexed_array = $form.serializeArray(); | |
var indexed_array = {}; | |
$.map(unindexed_array, function (n, i) { | |
if (n["name"].indexOf('[]') >= 0) { | |
var key = n["name"].slice(0, -2); | |
if (!indexed_array[key]) indexed_array[key] = []; | |
indexed_array[key].push(n['value']); | |
// } else { | |
indexed_array[n['name']] = n['value']; | |
} | |
}); | |
return indexed_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment