jquery - 是否可以使用 Jquery Ajax 调用控制器并在视图中加载模型(而不是在部分视图中)
问题描述
我现在有一个使用 ajax 调用控制器的代码,它工作正常。当我即将在视图中加载模型时,我现在的问题。我有一个 jquery 错误。还要注意我重用视图来加载模型
阿贾克斯代码
$.ajax({
type: 'POST',
url: '@Url.Action("GetEmployeeDetails", "Employee")',
contentType: "application/json; charset=utf-8",
dataType: 'json',
cache: false,
success: function (data) {
//how to load the data in the index view?
},
error: function () {
alert("Connection Failed. Please Try Again.");
}
});
在员工控制器中
[HttpPost]
public ActionResult GetEmployeeDetails()
{
var model = new EmployeeDetails();// I got the logic inside of this
//reused the existing view
return View("Index", model);
}
我对其进行了调试,并确认我可以通过直到将模型返回给 View 然后我将在 AJAX 中出现错误
解决方案
推荐阅读
- javascript - Safari 从 DOM 分离元素后调用事件处理程序
- node.js - 让管理员应用程序使用某些 api 密钥为另一个应用程序中的用户预订服务
- python - Azure 函数 Blob 触发器失败 - Python
- function - 如何在 Vuejs 中创建可重用的函数?
- wkwebview - WKWebView 冻结应用程序 iOS 14,无法显示带有标识符 _UIDatePickerCompactEditor 的配置上下文菜单
- python - Python子模块类实例生成
- flutter - Flutter Visual Studio 模拟器打开后我的程序失败
- spring - 当您将特定的 Spring bean 返回给休息端点的任何消费者时会发生什么
- c# - Ajax 如何将表单数据与 ID 一起发送到控制器
- ssis - 如何将 SQL Server 数据中的值分配给 SSIS 中的变量