【发布时间】:2020-08-24 02:16:31
【问题描述】:
JS:
newRecords = [{
"id": 7,
"name": "Raddish",
"rate": 30,
"weight": "2",
"amountperweight": 60
},
{
"id": 8,
"name": "Peas",
"rate": 35,
"weight": "4",
"amountperweight": 140
}
]
$.ajax({
method: "POST",
url: "http://localhost:36551/Orders/GenerateOrder",
data: ({
"generateOrder": newRecords
}),
contentType: "application/json, charset=utf-8",
success: function(response) {
console.log("response", response);
},
error: function(error) {}
});
Asp.Net:
public class OrderCart
{
public int id { get; set; }
public string name { get; set; }
public int rate { get; set; }
public string weight { get; set; }
public int amountperweight { get; set; }
}
[HttpPost]
[Route("GenerateOrder")]
[ActionName("GenerateOrder")]
public List<OrderCart> GenerateOrder(List<OrderCart> generateOrder)
{
return generateOrder;
}
VS 中的 Ajax Post 响应:
【问题讨论】:
标签: jquery asp.net ajax api postman