Chuyển data từ View sang Controller sử dụng ajax jquery

Xin chào các bậc tiền bối!

Em đang làm thử việc chuyển dữ liệu từ View sang Controller trong ASP.NET CORE.

Bên View em viết như sau:

<div class="form-group">
                <label class="control-label">Step Name</label>
                @Html.DropDownList("StepName", null, "Step", new { @class = "form-control", @required = "required" })
</div>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#StepName").change(function (e) {
            var options = {};
            options.url = "/Input/CheckValue";
            options.type = "POST";
            options.dataType = "json";
            options.contentType = "application/json";
            options.data = JSON.stringify({ StepName: $("#StepName").val() });
            options.success = function (response) {
                if (response == 0) {
                    alert("This Step is not active");
                    $("#SerialNumber").prop("disabled", true);
                    $("input").prop("disabled", true);
                }
            };
            options.error = function () { alert("Error retrieving states!"); };
            $.ajax(options);
        });
    });
</script>

Bên Controller:

[HttpPost]
        public JsonResult CheckValue(string StepName)
        {
            var IsActive = _context.ProcessStep.Where(p=>p.StepName == StepName).Select(p=>p.StepId).FirstOrDefault();
            return Json(IsActive);
        }

Nhưng hiện tại bên Controller em không hứng được dữ liệu của StepName khi gọi từ View qua khi có sự kiện change xảy ra.

Mong các cao nhân cho em lời khuyên và chỗ em còn thiếu sót. Em cám ơn mọi người ạ!

Sửa đoạn này
options.data = JSON.stringify({ StepName: $("#StepName").val() });

thành
options.data ={StepName: $("#StepName").val() }

Viết cách này cho ngắn gọn:

 $.post("/Input/CheckValue/",
{StepName: $("#StepName").val() }).done((response) => {
                 if (response == 0) {
                     alert("This Step is not active");
                     $("#SerialNumber").prop("disabled", true);
                     $("input").prop("disabled", true);
                 }
});

*Lưu ý: JSON.stringify() chỉ để dùng chuyển đổi object thành chuỗi string.
https://www.w3schools.com/js/js_json_stringify.asp

Dạ vâng em cám ơn sư huynh Leo2T ạ!

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?