Ich versuche, Liste an Controller-Methode mit Ajax übergeben. Beispiel Ich bin 2 Objekte in der Liste wie unten. Ich erhalte zwei Objekte in der Steuerung, aber innerhalb Eigenschaften sind null
Übergabe Liste der Objekte in der Steuerung mit Ajax Anruf
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;
}
noch habe ich versucht, var dataObject = { 'sections': json.stringify(sectionsOrder)};
noch nichts arbeiten. Was könnte das Problem sein?
In-Konsole, bevor er Werte
Ohne das vollständige Modell (in js und in C#) ist es sehr schwer zu sagen, was passiert, fügen Sie es in den Code. – Gusman
Was ist Ihre 'CustomAjaxRequest()' Methode? Ihre Ajax-Optionen müssen 'data: JSON.stringify (dataObject),' und 'contentType: 'application/json; charset = utf-8 ', ' –