Skip to content

Instantly share code, notes, and snippets.

@jsakhil
Forked from sweetleon/ajax.autosave.naive.html
Created April 14, 2022 09:48
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 jsakhil/75d211b49d2a224a020aa2dec338dafa to your computer and use it in GitHub Desktop.
Save jsakhil/75d211b49d2a224a020aa2dec338dafa to your computer and use it in GitHub Desktop.
naive AJAX auto-save implementation
<form method="POST" action="/our/url">
<textarea name="input" onChange="save(event)" />
</form>
<script language="javascript">
function save(event) {
var request = new XMLHttpRequest();
request.open(event.target.form.method, event.target.form.action);
request.send(new FormData(event.target.form));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment