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);

 

 

  

 

posted on 2014-08-22 15:42  【波少】  阅读(280)  评论(0编辑  收藏  举报

导航