在Ajax POST

时间:2017-05-19 20:09:23

标签: c# ajax asp.net-mvc

我有一个ASP.NET MVC包装类,它包装了一个包含ViewModels的List:

public class ScheduleContainerViewModel
{
    public List<SchedulingViewModel> Items { get; set; }

    public ScheduleContainerViewModel(List<SchedulingViewModel> items)
    {
        Items = items;
}

SchedulingViewModel包含Schedule个对象和Users个对象。

ScheduleContainerViewModel最终会传递给PartialView。 通过Ajax调用此PartialView来填充View中的div。 PartialView的模型为ScheduleContainerViewModelView的模型为Job

Ajax GET很棒。但是,当我尝试POST时,从不调用Controller,我收到500服务器错误。以下是POST编辑的部分XHR数据: enter image description here

在我看来,列表Items正在传递,包含SchedulingViewModel个及其关联的Schedules,但可能不是?

Controller中有三种相关方法。以下是他们的签名:

public ActionResult ScheduleJob(int? id)
public ActionResult Table(int? id)
[HttpPost]
public ActionResult Table(ScheduleContainerViewModel cvm)

ScheduleJob加载初始视图,调用[HttpGet] Table加载PartialView。最后,[HttpPost] TablePOST编辑的View。为什么模型绑定器可以看到在XHR中传递给它的数据?

我唯一的猜测是,因为ScheduleJob调用的POST使用的模型与[HttpPost] Table <j:set var="myvar" value="${it.getAction('org.jenkinsci.plugins.workflow.cps.EnvActionImpl').getOverriddenEnvironment()}"/> <p>My var: ${myvar}</p> 调用的模型不同。

0 个答案:

没有答案