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   【波少】  阅读(280)  评论(0编辑  收藏  举报

编辑推荐:
· 后端思维之高并发处理方案
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
阅读排行:
· 后端思维之高并发处理方案
· 千万级大表的优化技巧
· 在 VS Code 中,一键安装 MCP Server!
· 10年+ .NET Coder 心语 ── 继承的思维:从思维模式到架构设计的深度解析
· 上周热点回顾(3.24-3.30)

导航

< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

统计

点击右上角即可分享
微信分享提示