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;
}
Ajax Post response in VS:
2
Answers
Client-side code will look like this:
Server-side action will be:
Now Visual studio should work as expected.
Change the row data in
if the variable newRecords is in the format
do this