我想通过列表控制器方法使用ajax。例如我在下面的列表中有2个对象。我得到的控制器的两个对象,但里面性能null
传递控制器中使用ajax调用的对象列表
var dataObject = { 'sections': sectionsOrder};
console.log(dataObject);
CustomAjaxRequest("Post", "@Url.Action("UpdateOrderHoldingsForSections", "Renewal")" ,
dataObject, "json", "UpdateSectionsViewWithLatestOrderHoldings",
null, true);
[HttpPost]
public ActionResult UpdateOrderHoldingsForSections(List<OrderHoldings> sections)
{
return null;
}
即使我尝试var dataObject = { 'sections': json.stringify(sectionsOrder)};
仍然没有工作。可能是什么问题呢?
在控制台前值传递
没有完整的模型(在js和C#中),很难说出发生了什么,将它添加到代码中。 – Gusman
你的CustomAjaxRequest()方法是什么?你的ajax选项需要是'data:JSON.stringify(dataObject),'和'contentType:'application/json; charset = utf-8',' –