I have the following function:
var form = $("#formEditarCompra");
var meioPublicacao = $("#MeioPublicacao").val();
if (form.valid() && setarFocoErro()) {
mostrarAguarde();
$.post(form.attr("action"), { compra: form.serialize(), tipoMeioPublicacao: meioPublicacao }, function(data) {
var result = data;
if (result.Erro) {
mostrarAlerta(result.ErroMsg, 3, "erro");
} else {
mostrarAlerta(result.SucessoMsg, 5);
gridCompra.fnDraw();
}
esconderAguarde();
});
}
And in Controller the following Action:
public ActionResult Editar(Compra compra, string tipoMeioPublicacao);
In%% I can not get the two variables to be filled, so it's in function, only the TypePublication type is filled and the Purchase is null. I tried to use a serialized object too, as follows:
var compraEditar = {
compra: form.serialize(),
tipoMeioPublicacao: meioPublicacao
}
$.post(form.attr("action"), JSON.stringify(compraEditar), function (data)
In this way, the Purchase is completed, however the typePublication goes null.
How do I send everything in post
?