• Jquery 关于请求 及解析方式


    1、Json解析、POST

      

    $.post("@Url.Action("EverbrightBankCity", "ContractPost")", { City: city, ApplyCode: ApplyCode }, function (data) {
    
    var json = eval(data);
    var optionStrCity = json.optionStrCity;
    var optionStrBank = json.optionStrBank;
    $("#City").html(optionStrCity);
    $("#CustodianBankName").html(optionStrBank);
    });
    View Code

    2、toJson (Json提交list对象)

    function UpdateOrAddDocumentType(onSuccess) {
            var objArray = new Array();
            $("#DetainDocument ul").each(function (i) {
                var obj = new Object();
                obj.ApplyCode = "@Model[0].ApplyCode";
                obj.OrderBY = parseInt(i + 1);
                obj.SignID = $(this).find("select").val();
                obj.SignName = $(this).find("select").find("option:selected").text();
                var SignDocumentID = "";
                var SignDocumentName = "";
                $(this).find(":checkbox").each(function (i) {
                    if ($(this).attr("checked") == "checked") {
                        SignDocumentID += $(this).val() + ",";
                        SignDocumentName += $.trim($(this).parent().text()) + ",";
                    }
                });
                obj.SignDocumentID = SignDocumentID;
                obj.SignDocumentName = SignDocumentName;
                objArray.push(obj);
            });
            var postData = $.toJSON(objArray);
            $.ajax({
                async: "false",
                type: "POST",
                url: "@Url.Action("UpdateDocumentType", "ContractPost")",
                data: { postData: postData },
                success: function (data) {
                    if (data == "true") {
                        onSuccess();
                    }
                    else {
                        alert("收押证件类型保存失败!");
                    }
                }
            });
        }
    View Code

     3.表单序列化

    var postData = $('#CoborrowerInfo').serialize()

  • 相关阅读:
    Vimium -为键盘而生
    Sublime Text 3 修改配色主题【侧边框之...】
    MyBatis-Plus文档地址
    解决:电脑新建文件后需要刷新才显示
    技术书籍博客
    js获取浏览器当前窗口的高度长度
    DataGridView隐藏列用CSS实现
    判断windows操作系统平台
    iis7.5错误 配置错误
    vmware安装mac
  • 原文地址:https://www.cnblogs.com/eric-gms/p/5594248.html
Copyright © 2020-2023  润新知