Jquery ajaxSubmit 使用

js

jquery.form.js

 $('#formAddSubjectProduct').ajaxSubmit({
            beforeSubmit: function () {
                LoadMsgBegin("保存中...");
            },
            error: function () {
                LoadMsgEnd();
            },
            success: function (html, status) {
                if (typeof (html) == "string") {
                    var rs = html.substring(html.indexOf("{"), html.indexOf("}") + 1);
                    data = eval("(" + rs + ")");
                }
                else {
                    data = html;
                }
                LoadMsgEnd();
                if (data.result == "1") {
                    alert(data.message);
                    window.location.href = data.Url;
                    return true;
                } else {
                    alert(data.message);
                    return false;
                }
            }
        });

服务端返回json

 return Json(new { result = "1", message = _message, Url = _url }, "text/plain", Encoding.UTF8);

  

原文地址:https://www.cnblogs.com/WolfBlog/p/3929577.html