我有一个选项可以将每个项目添加到存档中,现在我正在尝试显示所有存档项目。
$.post("@Url.Action("ShowArchive", "Project")");
项目控制器中的ShowArchive:
public JsonResult ShowArchive(int id)
{
List<Project> projectList = (List<Project>)projectService.ShowArchivebyid(id);
return Json(projectList.ConvertAll<object>(Project.ToJsonObject), JsonRequestBehavior.AllowGet);
}
public IEnumerable<Project> ShowArchivebyid(int id)
{
Project project = GetProject(id);
Expression<Func<Project, bool>> constraint = null;
constraint = e => (e.Archive == 1);
IEnumerable<Project> result_list = projectRepository.GetMany(constraint);
return result_list.ToList<Project>();
}
在javascript控制台中:
POST http://localhost:4991/Project/ShowArchive 500 (Internal Server Error) library.min.js:4
send library.min.js:4
f.extend.ajax library.min.js:4
f.(anonymous function) library.min.js:4
(anonymous function) localhost/:417
f.event.dispatch library.min.js:3
h.handle.i
答案 0 :(得分:1)
您需要将javascript调用更新为...
$.post("@Url.Action("ShowArchive", "Project", new { id = your_id } )");
(未测试的)