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

前端 未结 13 1575
逝去的感伤
逝去的感伤 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");
        }
    });
    
    0 讨论(0)
提交回复
热议问题