Passing A List Of Objects Into An MVC Controller Method Using jQuery Ajax

前端 未结 13 1595
逝去的感伤
逝去的感伤 2020-11-22 14:22

I\'m trying to pass an array of objects into an MVC controller method using jQuery\'s ajax() function. When I get into the PassThing() C# controller method, the argument \"t

13条回答
  •  情话喂你
    2020-11-22 14:52

         var List = @Html.Raw(Json.Encode(Model));
    $.ajax({
        type: 'post',
        url: '/Controller/action',
        data:JSON.stringify({ 'item': List}),
        contentType: 'application/json; charset=utf-8',
        success: function (response) {
            //do your actions
        },
        error: function (response) {
            alert("error occured");
        }
    });
    

提交回复
热议问题