jquery 序列化
//生成发件人Json信息 function buildSenderInfoJson() { var sendName = $("#SendName").val(); var sendMobile = $("#SendMobile").val(); var sendAddress = $("#SendAddress").val(); var sendMail = $("#SendMail").val(); var sender = { Name: sendName, Mobile: sendMobile, Mail: sendMail, Address: sendAddress }; $("#SenderInfo").val(JSON.stringify(sender)); }
//生成货物Json信息 function buildGoodsInfoJson() { var array = new Array(); $(".tb_goods .tr_data").each(function (i, e) { var goodsCNName = $(e).find(".GoodsCNName").val(); var goodsENName = $(e).find(".GoodsENName").val(); var goodsCount = $(e).find(".GoodsCount").val(); var price = $(e).find(".Price").val(); var currencyType = $(e).find(".CurrencyType").val(); var buyShopUrl = $(e).find(".BuyShopUrl").val(); var goodsCustomsNo = $(e).find(".GoodsCustomsNo").val(); var goods = { GoodsCNName: goodsCNName, GoodsENName: goodsENName, GoodsCount: goodsCount, Price: price, CurrencyType: currencyType, BuyShopUrl: buyShopUrl, GoodsCustomsNo: goodsCustomsNo, }; array.push(goods); }); $("#GoodsModelJosn").val(JSON.stringify(array)); }