I am struggling to figure out how to pass a full list using Ajax. I have a C# list in my cshtml file and I need to send it to the controller through Ajax. While I know how to pass simple variables, passing a full list of objects is proving to be a challenge. Below is a snippet of my current JS script:
$.get("/home/function?List=" + SthList, function (r) {
$("#Table").html(r);
});
The issue appears to be that SthList
is not a JSON object. Using Razor does not seem to make a difference either.
My controller looks like this:
public ActionResult function(List<Object> List)
{
...
return PartialView(sth);
}
If you have any tips or suggestions on how to properly pass a full list via Ajax, I would greatly appreciate it!