I'm processing some client data in a js function, and I need to pass the variable to a controller action. This is my function:
function Save() {
var matrixIds = [];
//Do something
//Then create the URL and pass the parameter
document.location = "ConciliacionItem/DetallesConciliacionManual/" + $.param({ matriz : matrixIds });
So far I've tried with several methods but I can't get to the Controller Action. The only thing that did work was to use an Ajax call like this one:
setTimeout(function () {
$.ajax({
type: "POST",
url: myUrl,
data: JSON.stringify({
matriz: matrixIds
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true
});
}, 500);
If i do this, I have the following problem: I need to process the data sent from this view, and the result goes to another view, like this:
public ActionResult DetallesConciliacionManual(int[][] matriz)
{
//Variable to process
List<ConciliacionItem> listasAConciliar = new List<ConciliacionItem>();
//Do a lot of things
return View(listasAConciliar);
}
So, what I need to do is to be able to pass the js variable of my function to this action, to continue with the app workflow. Is it possible in any way?
Thanks in advance.