Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Periodically autosave form

How to implement a periodical save of a form in the background? Same kinda thing that gmail does.

like image 456
krunal shah Avatar asked Apr 27 '11 13:04

krunal shah


People also ask

How do I set up autosave on Google Forms?

When you fill out a Google Form in your Google account, your progress is automatically saved as a draft for 30 days. This means if you can't complete a form or need to switch devices, you don't have to start over the next time you open the form. Important: If you're offline, autosave doesn't work.

Is it autosave or auto save?

verb (used without object), au·to·saved, au·to·sav·ing. to be automatically saved: Most video games autosave after each new level.

How do I turn off autosave work in Google Forms?

To disable this feature, within Google Forms, go to Settings > Presentation > Restrictions and select “Disable autosave for all respondents”.


1 Answers

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);                                              // do it every 10 seconds

If you don't want to use the method of the form, but always want to use 'post', then use:

$.post(action, form.serialize(), ... );

And, if you want to supply your own action for the autosave that is different from the action for the actual save:

$.post("/autosave/comments", form.serialize(), ... );
like image 102
Phrogz Avatar answered Oct 07 '22 00:10

Phrogz