码迷,mamicode.com
首页 > Web开发 > 详细

Jquery 关于请求 及解析方式

时间:2016-06-17 16:45:57      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

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

 

Jquery 关于请求 及解析方式

标签:

原文地址:http://www.cnblogs.com/eric-gms/p/5594248.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!