首页 > 解决方案 > JsonResult 不返回 ajax 调用

问题描述

这是我的控制器

    [HttpPost]
    public JsonResult Index(parameters)
    {
       return Json(new { Status = "Success" }, JsonRequestBehavior.AllowGet);
    }

这是我成功运行 MVC 方法的 AJax 调用。

    $.ajax({
            contentType: 'application/json',
            type: 'POST',
            url: "/Home/Index",
            data: data,
            success: function (result) {
                debugger
                if (result == "error") {
                    swal({ text: "No procesado", type: "warning" });
                }
                else {
                    swal({ text: "Correcto", type: "success" });
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log(textStatus, errorThrown);
            }
            });

值没有返回到 Ajax 方法,结果留在浏览器中,也许 Visual Studio 中需要一些配置?

浏览器中的返回

标签: c#ajaxasp.net-mvc

解决方案


推荐阅读