Skip to content

Instantly share code, notes, and snippets.

@evolutionxbox
Created June 23, 2017 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evolutionxbox/91f35b24b0a0dff7cad64339d95d8198 to your computer and use it in GitHub Desktop.
Save evolutionxbox/91f35b24b0a0dff7cad64339d95d8198 to your computer and use it in GitHub Desktop.
Simple Serialize Form Data
// 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