ドロップダウンリストが変更されたときに表示されます。選択した値をajaxを使用してコントローラーに入れたい
$(document).ready(function () {
$("#otherCatches").change(function () {
$.ajax({
url: "Clients/DDL",
type: "POST",
data: {
name: $('#othercatches').val()
},
success: function (result) {
alert(result)
}
});
return false;
});
});
<select id ="otherCatches">
@foreach (var item in Model.Sample)
{
<option>
@item.SampleName
</option>
}
</select>
コントローラーに当たっていません
[HttpPost]
public virtual ActionResult DDL(int name)
{
//do method here
}