var name = "Kishan";
var marks = 76;
var employees = [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName": "Jones" }
var data1= [{ "fname": "Danny", "lname": "LaRusso", "phones":employees}];
$.ajax({
url:'@Url.Action("test", "controller")',
data: JSON.stringify(data1),
type: 'POST',
contentType: 'application/json;',
dataType: 'json',
success: function (result) {
}
});
In model
public class Person
{
public string fname{ get; set; }
public string lname{ get; set; }
public List<phone> phones { get; set; }
}
public class Phone
{
public string firstName { get; set; }
public string lastName { get; set; }
}
and then controller
public ActionResult test(List<person> person)
{
return View(person);
}
it should work fine.
tell if it is not work</person></phone>