我正在使用DataTables,并希望使用Ajax加载我的数据。但是加载页面时出现此错误:
DataTables警告:表id = example-请求的未知参数'DocentID'用于第0行第0列。有关此错误的更多信息,请参见http://datatables.net/tn/4
我不知道我在做什么错,这是我的 数据表脚本:
$(document).ready(function() {
$("#example").DataTable({
"ajax": {
"url": "assets/includes/ajax.php",
"dataSrc": ""
},
"columns": [
{"data": "DocentID"}
]
});
});
我的ajax.php文件及其回声
include_once('DB_Handler.php');
$result = mysqli_query($mysqli, "SELECT DocentID FROM gebruiker");
$rows = array();
while ( $row = mysqli_fetch_array($result))
{
$rows[] = json_encode($row);
}
echo json_encode($rows);
数组:
["{\"0\":\"0\",\"DocentID\":\"0\"}","{\"0\":\"67\",\"DocentID\":\"67\"}","{\"0\":\"0\",\"DocentID\":\"0\"}","{\"0\":\"0\",\"DocentID\":\"0\"}"]
答案 0 :(得分:0)
尝试删除第一个@Table(name = "invoice")
public class InvoiceEntity {
@OneToMany(mappedBy = "futureInvoice", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<CorrectionEntity> corrections;
}
@Table(name = "correction")
public class CorrectionEntity extends BaseTimestampedEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "future_invoice_id")
private InvoiceEntity invoice;
}
。无需对其进行两次编码。
json_encode()