In the development process, you will definitely encounter form submission and pass value. The previous practice was to put a hidden input tag on the page to give a
name and then put a value, and submit this value to the background when submitting. But this way would be very insecure.
Therefore, there is a new way to solve the problem of form submission passing by value:
<form style="display:none" method="get">
<input name="addressId" type="hidden" value="@ViewBag.AddressId" />
<input name="cartIds" type="hidden" value="@ViewBag.CartIds" />
</form>
<script>
$('.paytbn').click(function () {
var cartIds = $('form input[name=cartIds]').val();
var addressId = $('form input[name=addressId]').val();
var referNo = $('.order-referno').val();
var logistics = [];
$.each($('select.logistics'), function () {
var table = $(this).parents('.goods-table');
var map = table.attr('data-wareid') + '|' + $(this).val();
logistics.push(map);
});
if (logistics.length < 1) {
ZTLayer.showTips('@T("Order.PleaseChooseSendway")', 2);
return;
}
$.post('@Url.Action("SubmitOrder")', { cartIds: cartIds, addressId: addressId, logistics:logistics, referNo: referNo },
function (data) {
if (data.flag) {
location.href = '@Url.RouteUrl("PaymentOrder")' + "?orderNos=" + data.msg;
} else {
if (data.redirect) {
location.href = data.redirect;
} else {
ZTLayer.showTips(data.msg, 2);
}
}
});
});