본문 바로가기
개발/ASP.NET

ASP.NET MVC : Ajax로 리스트 오브젝트를 Controller로 전달하기

by ispie 2019. 1. 24.

Ajax로 리스트 오브젝트를 Controller로 전달하기

 

JS

var things = [
    { id: 1, color: 'yellow' },
    { id: 2, color: 'blue' },
    { id: 3, color: 'red' }
];
$.post('@Url.Action("PassThings")', { things: things },
   function () {
        $('#result').html('"PassThings()" successfully called.');
   });

 

Controller

[HttpPost]
public void PassThings(IEnumerable<Thing> things)
{
    // do stuff with things here...
}

 

 

댓글