MVC 3 AJAX Post, List filled with Objects, but Objects Properties are Empty

前端 未结 3 2095
离开以前
离开以前 2021-01-12 02:06

I have the following problem:

On a Button-Click I POST some data to the server. My controller Action looks like this:

public ActionResult Accept(List         


        
3条回答
  •  心在旅途
    2021-01-12 02:13

    With your answer and the use of JSON.stringify method it works for me

    var myEntries = { entries: [{ ParamA: "A", ParamB: "B" }, 
                                { ParamA: "C", ParamB: "D" }] };
    
    $.ajax({
            type: 'POST',
            url: '/{controller}/{action}',
            cache: false,
            data: JSON.stringify(myEntries),
            dataType: 'json', 
            contentType: 'application/json; charset=utf-8'
        });
    

提交回复
热议问题