public JsonResult Home(string userName, string password, string type) { List<person> list = new List<person>(); person li = new person(); li.name = "111"; li.gender = "1"; li.name = "222"; li.gender = "2"; list.Add(li); person li2 = new person(); li2.name = "333"; li2.gender = "33"; li2.name = "333333"; li2.gender = "454"; list.Add(li2); return Json(list, JsonRequestBehavior.AllowGet); }
直接通过这种方法在controller中返回json格式的数据对象,这样在js中进行解析拆分,在需要用到的地方,进行展现