I have a page with a table, with one column, using DataTables; i load data with an ajax call.
Data are returned to the page but table show no row. I don't have any error show on browser.
This is my HTML with JQuery:
<div>
<table class="table table-bordered" id="DetailsTable" width="100%" cellspacing="0"</table>
</div>
<script>
jQuery(function () {
$('#DetailsTable').DataTable({
"responsive": true,
"processing": true,
"serverSide": true,
"ajax": {
"url": "/Index?handler=Table",
"type": "GET",
"dataSrc": "",
"dataType": "json"
},
"columnDefs": [
{ "targets": "detail_ID", visible: true }
],
"columns": [
{ "data": "detail_ID" }]
});
});
</script>
This is my method:
public async Task<IActionResult> OnGetTableAsync()
{
wItem = await _detailRepo.Finddetail(CancellationToken.None);
string NewtonJSON = JsonConvert.SerializeObject(wItem);
return Content(NewtonJSON);
}
and this is reurned JSON:
{
"detail_ID": 7,
"detail_GUID": "685b8741-fe22-460a-bb76-7ecd9c320172"
}
Any suggestion?