asp.net-mvc – 使用jQuery ASP.NET MVC自动保存表单输入

我们希望实现一个自动保存内容的网络表单.类似于gmail / google docs的东西自动保存功能.

有人可以建议如何使用ASP.NET MVC jQuery实现这一点吗?

解决方法

jQuery Forms plugin和ASP.NET MVC操作应该完成这项工作:
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 });
}

在您的视图中,只需定期调用此操作:

setInterval(function() {
    $('#theFormToSave').ajaxSubmit({ 
        url    : 'SaveDraft',success: function (data,textStatus) {
            if (data.success) {
                alert('form successfully saved');
            }
        }
    });
},30000);

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....