I have, for example, 3 radio buttons. I want to click on them to call the action method needed from the controller. I do not know how to do this through jQuery. Or are there other options?

<h3>Пол:</h3> @Html.RadioButton("Gender", "All", true, new {id = "radioAll"}) @Html.Label("Все") <br/> @Html.RadioButton("Gender", "Male", false, new {id = "radioMale"}) @Html.Label("Мужской") <br/> @Html.RadioButton("Gender", "Female", false, new {id = "radioFemale"}) @Html.Label("Женский") // я пытался пользоваться разными вариантами, но зашёл в тупик. <script> $(document).ready(function () { var url = '@Url.Action("ShowUsers", "Home")'; if ($("#radioMale").attr("checked") === "checked") { $.post(url, 'choice=' + "Male"); } }); </script> 

    1 answer 1

    It is done as follows:

     if ($('#radioMale').prop('checked')) { // bool - значение (true-если выбрано, false-если нет) ... }