asp.net - 使用ajax获取多个模型的数据
问题描述
我正在使用 dapper 获取数据库中的数据,并希望使用该值。我是 ajax 新手,所以我无法访问数据。我在模型和控制器页面中没有任何问题。我调试了,它工作正常,我在 ajax 中的问题。
型号代码:https
://imgur.com/a/qqbRxZi Case.cs 文件中的 Dapper 代码: https
://imgur.com/a/MpWv27r
控制器代码:https ://imgur.com/a/VMHB0QI
我试过这样:
$.ajax({
type: "post",
url: "@Url.Action("Select_Items", "Case")",
data: JSON.stringify({ "bas_trh": bas_trh, "bts_trh": bts_trh}),
contentType: "application/json; charset=utf-8",
success: function (response) {
$.each(response, function (index, value) {
alert(value.unvan);
})
}
});
当我进行调试时,它看起来像那样,但我无法访问 vales:https ://imgur.com/a/L3MA6sH
解决方案
you value it seems have three object of array "value (3)". try access it by array id
alert(value[0]);
alert(value[1]);
alert(value[2]);
推荐阅读
- sorting - 如何在select2中按字母顺序进行选定和未选定排序?
- react-navigation - route.params 在 useFocusEffect() 中不可见
- sql - 将 SQL 代码(作为字符串)转换为表 - 动态数据透视
- firebase - NoSuchMethodError。getter 'weekday' 被调用为 null。Table_Calendar Flutter
- javascript - 基于 state.vallue 值 reactjs 隐藏/取消隐藏操作图标
- python-3.x - Spyder,干净的 Win 安装,版本。4.2.3 - pip 给出消息“没有名为 pip 的模块”
- php - 如何使包含转义序列和反斜杠的json有效?
- php - PHP Regex 忽略注释行
- ios - 我的导航栏和警报标题以及底部警报标题在整个项目中变为白色
- python - 如何在光线追踪迷宫之前运行动画屏幕(python asciimatics)