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...
}
'개발 > ASP.NET' 카테고리의 다른 글
.NET MVC의 Web API에 Basic인증을 적용하는 방법 (0) | 2019.01.25 |
---|---|
Json내의 html태그의 이스케이프(Escape) 처리 (0) | 2019.01.25 |
ASP.NET MVC : ModelState에서 에러 메세지를 취득하기 (0) | 2019.01.24 |
ASP.NET MVC : ModelState의 에러 메세지 리스트를 취득해서 Json으로 반환시키기 (0) | 2019.01.24 |
C# 자동 구현 속성(auto-property) (0) | 2019.01.24 |
댓글