I have a problem with sending JSON data from MVC View to Controller, all I get to Controller is:
where my JSON I send in Url.Action looks like this: (I create it by my own adding array to array by .push() and then JSON.stringify )
[ [ { "isOrdered":false, "orderLineId":"4550", "comment":"", "orderId":"2789" } ], [ { "isOrdered":false, "orderLineId":"4551", "comment":"", "orderId":"2789" } ] ]
I use JQuery ajax POST
$.ajax({ type: "POST", url: "@Url.Action("SaveCheckboxesAndComments")", data: JSON.stringify(array), traditional: true, contentType: "application/json; charset=utf-8", dataType: 'json' });
and my controller:
public class JsonData { public bool IsOrdered { get; set; } public string OrderLineId { get; set; } public string Comment { get; set; } public int OrderId { get; set; } } [HttpPost] public async Task<ActionResult> SaveCheckboxesAndComments(List<JsonData> jsonArray) {...
Should I change something in my class JsonData or in JS to get values? Because somehow the "frame" is working.