ドロップダウンがあります
<%=Html.DropDownList("genre", Model.genres, "", new { @onchange = ChangeMovie()" })%>
JavaScriptは(不完全)のように見えます
function ChangeMovie() {
var genreSelection = container.find( '#genre' ).val();
$.ajax({
"url" : "/Movies/GetGenre" ,
"type" : "get" ,
"dataType" : "json" ,
"data" : { "selectedValue" : $( "#genre").val() },
"success" : function (data) {}
});
};
コントローラーコード
public ActionResult GetGenre(string genreName)
{
//Need to get the `genreName` from the JavaScript function above.. which is
// in turn coming from the selected value of the drop down in the beginning.
}
ドロップダウンの選択した値を、js関数を介してコントローラーコードのアクション結果に渡したいです。正しい値がコントローラーに渡されるように、JavaScriptコードとAJAX呼び出しコードを操作するのに助けが必要です。