-1
我已经经历了这里所有的其他的答案看了,但找不到一个简单地陈述一个解决方案,我有错误,数据表请求的未知参数
我的JS代码:
$('#product-table').DataTable({
stateSave: true,
ajax: {
url: "/api/stock/products",
type: "POST",
"Columns": [
{ "data": "name" },
{ "data": "description" },
{ "data": "current_stock" },
{ "data": "cost_price" },
{ "data": "retail_price" }
]
},
});
JSON数据返回:
{
"data": [
{
"name": "product 1",
"description": "test product",
"current_stock": "200",
"cost_price": "2000",
"retail_price": "2500"
}
]
}
HTML:
<table id="product-table" width="100%" class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Current Stock</th>
<th>Cost Price</th>
<th>Retail price</th>
</tr>
</thead>
</table>
AJAX调用正在通过并返回数据发送,但只要在页面加载的DataTable引发以下错误:
DataTables warning: table id=product-table - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4