0

我有一个将每个项目添加到存档的选项,现在我正在尝试显示所有存档项目。

   $.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
4

1 回答 1

2

您需要将 javascript 调用更新为...

 $.post("@Url.Action("ShowArchive", "Project", new { id = your_id } )");

(未经测试)

于 2013-06-04T07:59:15.537 回答