As the title say, I need to send from a .js file some values to a MVC controller, one of that values is an object array that corresponds to an List<> in the controller, the problem is that when arrives to the controller the List count is 0, this is my code:
In the .js:
var listaParametros = [
{ "Identificador": "1", "Tipo": "MG", "Texto": "Escala de calificación", "Valor": "/EscalaCalificacion/Listado", "IdRetorno": identificadorRetorno, "RecuerdaFiltros": recuerdaFiltros }
];
var maestroEscalaCalificacionE =
{
IdentificadorMaestroEscalaCalificacion: $('#grid-tableEscalaCalificacion').jqGrid('getRowData', elementoSeleccionado).IdentificadorMaestroEscalaCalificacion,
IndicadorActivo: $('#ddlIndicadorActivo').val(),
ListaParametros: listaParametros
};
$.redirectPost(window.rootUrl + "/EscalaCalificacion/Consultar", maestroEscalaCalificacionE);
The ActionResult on the Controller:
[HttpPost]
public ActionResult Consultar(EscalaCalificacionMaestroE maestroEscalaCalificacionE)
The List is a public property of the class EscalaCalificacionMaestroE.
By the way, I'm using $.redirectPost() because I need to go to another page when the ActionResult finishes.
[UPDATE] This is the function redirectPost()
redirectPost: function (location, args) {
var form = '';
var jForm = $('<form></form>', {
action: location,
method: 'post'
});
$.each(args, function (key, value) {
$("<input>", {
name: key,
value: value,
type: 'hidden'
}).appendTo(jForm);
});
jForm.appendTo('body').submit();
}
Now, when I use $.ajax, all works like a charm, but don't know how to get the new page, any help on getting to the new page?