Model binding is not working the way I thought it would. I thought I could just make an array of objects and pass that to $.post but no, not that easy.
This is what I want to do
var a=new Array();
a[0]={
Name:"Eric",
Email:"eric@yahoo.com"
}
a[1]={
Name:"Peter",
Email:"peter@gmail.com"
}
$.post("/Home/SendPersons", a, function (data, status) {
$("#someid").html(data);
});
and in my controller:
public ActionResult SendPersons(IList<Person> persons) {
//Do stuff
return PartialView("Persons");
}
but the parameter is null. How do I do this correctly?