Skip to content

Instantly share code, notes, and snippets.

@sweetleon
Created January 17, 2018 01:18
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 sweetleon/ba4e91b0562f3d690b914713318f1d72 to your computer and use it in GitHub Desktop.
Save sweetleon/ba4e91b0562f3d690b914713318f1d72 to your computer and use it in GitHub Desktop.
<form method="POST" action="/our/url">
<!-- this should have the current value of version_number -->
<input type="hidden" name="version_number" value="1" />
<textarea name="input" onChange="save(event)" />
</form>
function save(event) {
event.target.form['version_number'].value++;
var request = new XMLHttpRequest();
request.open(event.target.form.method, event.target.form.action);
request.send(new FormData(event.target.form));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment