我想在选择下拉列表值时创建表行,但此时它什么也不返回。我尝试更改数据。注意到只有数据,但随后它返回“未定义”。
Returns Empty
检视:
<script>
$(document).ready(function () {
$('select').formSelect();
});
function onManagerChange() {
var id = $("#Managers").val();
var rows = "";
$.ajax({
type: "GET",
url: "@Url.Action("GetFilteredReports", "FinalReports")",
dataType: "application/json",
data: { "id": id },
success: function (data) {
$("#Reports").html("");
$.each(data.notices, function (id, report) {
rows += `
<tr> +
<td> + ${report.ReportName} + </td> +
<td> + ${report.ReportState} + </td> +
<td> + <a class="btn-small waves-effect waves-light" asp-action="Download" asp-route-id="report.ID">Download</a> + </td> +
</tr>`
});
$("#Reports").html(rows);
}
});
}
控制器:
public IActionResult GetFilteredReports(int id)
{
var reportsList = _context.Reports.Include(x => x.ReportManager).Where(x => x.ReportManager.ID == id).ToList();
return Json(reportsList);
}
1条答案
按热度按时间pod7payv1#
找到了答案,这就是解决办法
控制器:
查看方式: