We would like to implement a web form that automatically saves content at regular intervals.Something similar to gmail/google docs auto save funcationality.
Can some one suggest how to implement this using ASP.NET MVC + jQuery?
jQuery Forms plugin and an ASP.NET MVC action should do the job:
public ActionResult SaveDraft(FormCollection form)
{
// TODO: Save the form values and return a JSON result
// to indicate if the save went succesfully
return Json(new { success = true });
}
And in your View just invoke this action periodically:
setInterval(function() {
$('#theFormToSave').ajaxSubmit({
url : 'SaveDraft',
success: function (data, textStatus) {
if (data.success) {
alert('form successfully saved');
}
}
});
}, 30000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With