首页 > 解决方案 > 尝试在 MVC 5 中使用 AJAX POST 将数据传递给操作方法

问题描述

我正在尝试从 Jquery 的 Bootbox 文本区域捕获注释/评论并将其发送到接受参数的操作方法,但我没有达到该操作方法的断点。

我在 View.cshtml 中的 jquery:

 $(function () {
                if ($('#stafId').is(':checked')) {
                    bootbox.prompt({
                        title: "Please add Project Note for STAF selection",
                        inputType: 'textarea',
                        callback: function (result) {
                            $.ajax({
                                type: 'POST',
                                url: '/Requirement/SaveProjectNotes',
                                data: { notes: result } 
                            });
                        }
                    });
                }
            });

我在控制器中的操作方法:

[HttpPost]
    public ActionResult SaveProjectNotes(string notes)
    {
       // TODO :

        return RedirectToAction("Index", "Requirement", new { page = -1 });
    }

我不知道为什么我没有使用 action 方法。任何指针都会有很大帮助。

TIA。

标签: jqueryajaxasp.net-mvc-5

解决方案


推荐阅读