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); });
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("收押证件类型保存失败!"); } } }); }
3.表单序列化
var postData = $('#CoborrowerInfo').serialize()