сервер:
public class FormItems
{
public IEnumerable<MyClass> Values { get; set; }
}
клиент:
<form id="myform" action="/" method="post">
<!-- Those inputs could be added dynamically -->
<input type="text" name="[0].Value" />
<input type="text" name="[1].Value" />
<input type="text" name="[2].Value" />
<input type="text" name="[3].Value" />
<button type="submit">OK</button>
</form>
и, наконец, AJAXify форму:
$(function() {
$('#myform').submit(function() {
var form = $(this);
$.ajax({
url: form.attr('action'),
type: form.attr('method'),
data: form.serialize(),
success: function(result) {
}
});
});
});
Как я могу использовать связыватель модели по умолчанию получить ajaxданные в строго типизированный IEnumerable?
[HttpPost]
public JsonResult Save(FormItems data)