I have an array of data:
var myArray = [{"id": 1, "name", "John"},{"id": 2, "name", "Joe"},{"id": 3, "name", "Bill"}]
$.post("/MyController/Update", myArray, function (data) {
alert("Complete");
});
and here is my asp.net-mvc controller action
public ActionResult Update(List<Person> people)
{
return Json(new {Success = true});
}
public class Person
{
public int id {get;set;}
public string name {get;set;}
}
I also tried:
var paramString = JSON.stringify({ people: myArray});
$.post("/MyController/Update", paramString , function (data) {
alert("Complete");
});
but when i look at the people parameter on the server, I either see:
- null
- array of 3 items but the values of Id are always 0 and the value of Name is always an empty string
any suggestions on what I am doing wrong here?