首页 > 解决方案 > 使用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

标签: asp.netajaxmodel-view-controller

解决方案


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]);

推荐阅读