Created
June 23, 2017 12:04
-
-
Save evolutionxbox/91f35b24b0a0dff7cad64339d95d8198 to your computer and use it in GitHub Desktop.
Simple Serialize Form Data
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
// Serialize form data | |
function serialize (form) { | |
return [...form.elements] | |
.filter(element => element.type !== 'radio' || element.checked) | |
.map(element => element.name + '=' + encodeURIComponent(element.value)) | |
.join('&'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment