【发布时间】:2025-12-18 02:50:02
【问题描述】:
如何将 json linq 返回的列表显示到视图中? 我尝试如下,但无法获取列表值。
$("#Admission_No").live("change", function () {
var adminssionNo = $(this).val();
$.getJSON("/../Student_Fee_Allocation/GetStuDetails", { adminssionNo: adminssionNo }, function (list) {
if (list.length) {
alert(list.Registration_Id);
} alert(result.Re_Admission_Id);
});
// $.ajax({
// type: "GET",
// url: "/../Student_Fee_Allocation/GetStuDetails/",
// data: { adminssionNo: adminssionNo },
// contentType: "application/json;charset=utf-8",
// dataType: "json",
// success: function (result) {
// debugger;
// alert(result)
// },
// error: function (response) {
// debugger;
// alert('eror');
// }
// });
});
在 c# 中获取变量中的数据并以 json 形式返回。但从视图方面看没有任何响应,意味着没有得到任何值,甚至警报不起作用。
public JsonResult GetStuDetails(string adminssionNo)//long? compId, long? compLocId,
{
var list =
(from a in db.Student_Re_Admission
join b in db.Student_Registration on a.Registration_Id equals b.Registration_Id
where a.Admission_No == adminssionNo && b.Delete_Flag == false
orderby a.Re_Admission_Id descending
select new CUSTOM_STUDENT_FEEALLOCATION_DETAIL
{
Registration_Id=a.Registration_Id
}).First();
return Json(list, JsonRequestBehavior.AllowGet);
}
【问题讨论】:
标签: javascript c# linq model-view-controller