Last active
September 25, 2015 19:20
-
-
Save psorensen/83841db0e5bfc1966727 to your computer and use it in GitHub Desktop.
Convert form data to object
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 get_form_data($form){ | |
var search_form_data = $($form), | |
search_form_data_object = search_form_data.serializeArray(), | |
search_form_data_len = search_form_data_object.length; | |
// loop through object and asign key/value pairs | |
var returnObj = {}; | |
for (var i = 0; i < search_form_data_len; i++) { | |
returnObj[search_form_data_object[i].name] = search_form_data_object[i].value; | |
} | |
return returnObj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment