Skip to content

Instantly share code, notes, and snippets.

@adamrobbie
Created June 19, 2012 12:34
Show Gist options
  • Save adamrobbie/2953884 to your computer and use it in GitHub Desktop.
Save adamrobbie/2953884 to your computer and use it in GitHub Desktop.
A javascript that can add autosave to any form
setInterval(function(){
var form = $('#my-form-id');
var method = form.attr('method').toLowerCase(); // "get" or "post"
var action = form.attr('action'); // url to submit to
$[method](action, form.serialize(), function(data){
// Do something with the server response data
// Or at least let the user know it saved
});
},10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment