/*******在前段拼接Model,後臺直接用模型類去接收************/ //前端 --1 var data = []; data.push({ name: 'Id', value: "123" }), data.push({ name: 'Overage', value: "3%" ...
/*******在前段拼接Model,後臺直接用模型類去接收************/
//前端 --1
var data = [];
data.push({ name: 'Id', value: "123" }),
data.push({ name: 'Overage', value: "3%" }),
data.push({ name: 'SampleQty', value: "143" }),
data.push({ name: 'Qty', value: "123" }),
//非同步提交(直接傳data數組不用轉換和指定後臺接收的變數名稱)--2
$.ajax({
url: "/order/RfidOrder/ChangeDetailInfoee",
data: data,
success: function (data) {
}
});
//後臺定義接收--3
[Route("ChangeDetailInfoee")]
[ValidateInput(false)]
public void ChangeDetailInfoee(ListOption option)
{
}
/******直接在前段傳List集合,後臺用集合去接收,用索引更新Name****
//前端--1
var data = [];
data.push({ name: 'option[0].Id', value: "123" }),
data.push({ name: 'option[0].Overage', value: "3%" }),
data.push({ name: 'option[0].SampleQty', value: "143" }),
data.push({ name: 'option[0].Qty', value: "123" }),
data.push({ name: 'option[1].Id', value: "124" }),
data.push({ name: 'option[1].Overage', value: "4%" }),
data.push({ name: 'option[1].SampleQty', value: "144" }),
data.push({ name: 'option[1].Qty', value: "124" })
//非同步提交(通過指定後臺對應接收的變數名稱利用索引來對List集合進行填充)--2
$.ajax({
url: "/order/RfidOrder/ChangeDetailInfoee",
data: data,
success: function (data) {
}
});
//後臺定義接收--3
[Route("ChangeDetailInfoee")]
[ValidateInput(false)]
public void ChangeDetailInfoee(List<ListOption> option)
{
}
/*********ListOption********/
public class ListOption
{
public string Id { get; set; }
public string Overage { get; set; }
public string SampleQty { get; set; }
public string Qty { get; set; }
}