$.Ajax({});方法使用 返回json格式 string格式

//Json格式

$.ajax({
                url: url + "?action=Save1",
                type: "post",
                dataType: "json",//msg访问json格式,默认string
                data: { SNO: $('#SNO').val(), VenderCode: $("#gys_key").combogrid("getValue"), SDate: $('#dtpDate').datebox("getValue") },
                success: function (msg) {
                    if (msg3[0].flag != "0") {
                        //$("#dg").datagrid("reload");
                        $.messager.alert("提示", "保存成功!", "info");
                        $('#S_code').val(msg3[0].strmsg);
                    }
                    else {
                        $.messager.alert("提示", msg3[0].strmsg, "info");
                    }

                }
            });

 //返回string格式脚本

$.ajax({
                url: url + "?action=Save1",
                type: "post",
                dataType: "json",//msg访问json格式,默认string
                data: { SNO: $('#SNO').val(), VenderCode: $("#gys_key").combogrid("getValue"), SDate: $('#dtpDate').datebox("getValue") },
                success: function (msg) {
                    if (msg != "0") {
                        //$("#dg").datagrid("reload");
                        $.messager.alert("提示", "保存成功!", "info");
                    }
                    else {
                        $.messager.alert("提示", "保存失败", "info");
                    }

                }
            });

//后台

result = "[{"flag":"0","strmsg":"执行错误!"}]";

Response.Write(result);
Response.End();

原文地址:https://www.cnblogs.com/chirs888888/p/6248816.html