I need to pass the values of a view model, and a table, the table is passing normally, when passed alone, the viewmodel does not. Here's how I'm doing:
var model1 = objectifyForm(model);
console.log(model1);
debugger;
$.ajax({
url: '@Url.Action("Novo1", "PedidoFornecedor")',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: { valores: JSON.stringify(valores), model: model1 }
});
This is the function that takes the input from the form:
function objectifyForm(formArray) {//serialize data function
var returnArray = {};
for (var i = 0; i < formArray.length; i++) {
returnArray[formArray[i]['name']] = formArray[i]['value'];
}
return returnArray;
}
But in the controller, in any way I try, one comes empty, or it does not come with the correct data, how can I proceed?
[HttpPost]
public IActionResult Novo1([FromBody]List<PedidosProdutosF> valores, NovoViewModel model)
{
if (ModelState.IsValid)
{