c# - 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 中需要一些配置?
解决方案
推荐阅读
- php - 使用 API 和 Laravel Sanctum 进行电子邮件验证
- amazon-web-services - 未在 module.eip 中声明托管资源“aws_internet_gateway”“igw_id”
- c++ - 交换数组/向量中的所有最小和最大数字
- python - 如何在 python 上的 pyQt5 GUI 中创建和访问多个数据集?
- plugins - 用于路由电子邮件的 Dynamics CRM 插件消息
- python - QKeras/Python 中的轮回函数是什么?
- uml - 我安装了 ObjectAid UML,但看不到类关系线
- typescript - 使用 webpack 和 ts-loader 缓慢构建 typescript 项目
- javascript - Javascript-如何编写一个函数来查找任何一组数值参数中的最大数
- sql - 对 Athena 的分层 SQL 查询