「myArray」配列を mvc コントローラーに渡すにはどうすればよいですか? 私はすべてを試しましたが、何も機能しないようです
コントローラ
[HttpPost]
public ActionResult MyAction(MyModel model, List<string> myArray) {
//code...
}
意見
$('#dialog').dialog({
//...
buttons: {
"Cancel": function () {
$(this).dialog("close");
},
"Submit": function () {
var arrCount= 0;
var myArray = new Array();
//grabs all the dropdownlists that begin with id 'dropdownlist' and adds it to 'myArray'
$('form').contents().find("select[id ^= 'dropdownlist'] option:selected").each(function () {
myArray[arrCount++] = $(this).text();
});
if ($('form').validate().form()) {
$.ajax({
url: "MyController/MyAction",
type: 'POST',
dataType: "json",
traditional: true,
data: {
model: $("form").serialize(),
myArray: myArray
},
success: function (result) {
alert("debug: complete");
}
});
}
}
}
});
配列自体をコントローラーに渡す方法を知っています。しかし、既存のモデルを方程式に追加すると、配列をコントローラーに渡す方法がわかりません。何かご意見は?