Skip to content

Instantly share code, notes, and snippets.

@FullZero5
Created February 7, 2020 05:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FullZero5/85fb510deefbeb03ca8233d1f6ac31b6 to your computer and use it in GitHub Desktop.
Save FullZero5/85fb510deefbeb03ca8233d1f6ac31b6 to your computer and use it in GitHub Desktop.
js form
function send(e,form) {
fetch(form.action,{method:'post', body: new FormData(form)});
console.log('We send post asynchronously (AJAX)');
e.preventDefault();
}
/*<form method="POST" action="myapi/send" onsubmit="send(event,this)">
<input hidden name="crsfToken" value="a1e24s1">
<input name="email" value="a@b.com">
<input name="phone" value="123-456-789">
<input type="submit">
</form>*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment