• 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()

  • 相关阅读:
    157 判断字符串是否没有重复字符
    53 翻转字符串
    671 循环单词
    8 旋转字符串
    39 恢复旋转字符串
    6 合并排序数组 Ⅱ
    64 合并排序数组
    60 搜索插入位置
    141 x的平方根
    TCSRM 593 div2(1000)(dp)
  • 原文地址:https://www.cnblogs.com/eric-gms/p/5594248.html
Copyright © 2020-2023  润新知