问题描述
我有以下代码,可以使用数据表生成报告。 但它一直失败给我以下 jquery datatables 错误:
TypeError: d is undefined
...=f.nextSibling}else{d=b.anCells;f=0;for(b=d.length;f<b;f++)a(d[f])}return{data:e...
下面是我应该生成视图的代码,目前我只有一个空白
<!DOCTYPE html>
<html lang="en">
<head>
<!--
-->
<meta charset="utf-8">
<title>Care-tech System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Out patient Hospital Management System.">
<meta name="author" content="Harris Samuel Dindi">
</head>
<body>
<table id="test_trial" class="test_trial">
<thead>
<tr></tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
</body>
</html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script>
<link href='http://cdn.datatables.net/1.10.5/css/jquery.dataTables.css' rel='stylesheet'>
<script type="text/javascript">
$(document).ready(function () {
$("#test_trial").DataTable({
stateSave: true,
"bautoWidth": false,
"aoColumns": [
{"sTitle": "Commodity No", "mData": "commodity_id"},
{"sTitle": "Commodity Name.", "mData": "commodity_name"
},
{"sTitle": "Strength", "mData": "strength"},
{"sTitle": "Commodity code", "mData": "commodity_code"},
{"sTitle": "Type.", "mData": "commodity_type"},
{"sTitle": "Commodity unit", "mData": "commodity_unit"},
{"sTitle": "Max Stock", "mData": "max_stock"},
{"sTitle": "Min sTOCK", "mData": "min_stock"},
{"sTitle": "Remarks", "mData": "remarks"},
],
"bDeferRender": true,
"bProcessing": true,
"bDestroy": true,
"bLengthChange": true,
"iDisplayLength": 20,
"sAjaxDataProp": "",
"sAjaxSource": '<?php echo base_url() . "pharmacy/commodity_managements"; ?>',
"aaSorting": [[2, "desc"]]
});
});
</script>
我怎样才能消除错误?
1楼
kels
4
2020-01-14 20:03:43
TypeError: d is undefined 意味着您的服务器端 php 端点 URL (pharmacy/commodity_managements) 没有向网格返回任何数据。 尝试调试您的 php 响应。
2楼
Kevin Bonnett
-1
2015-10-05 16:03:18
Ishettyl 给出了部分正确的答案。 数据表版本是最新的,但正在使用的表属性来自数据表的旧版。 将所有表属性更改为 1.10.5 版本应该可以解决您的问题。 (例如:将“mData”更改为“data”等)