Javascript 不显示ajax数据的表格
我无法使用“表格”来显示包含数据的表格。已经在铬合金和Edge上进行了测试 main.jsJavascript 不显示ajax数据的表格,javascript,tabulator,Javascript,Tabulator,我无法使用“表格”来显示包含数据的表格。已经在铬合金和Edge上进行了测试 main.js let jsonURL = './readAllUsers.php'; var table = new Tabulator("#example-table", { ajaxURL: jsonURL, ajaxResponse: (url, params, response) => { console.log(response.data); retur
let jsonURL = './readAllUsers.php';
var table = new Tabulator("#example-table", {
ajaxURL: jsonURL,
ajaxResponse: (url, params, response) => {
console.log(response.data);
return response.data;
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Table</title>
<link href="/node_modules/tabulator-tables/dist/css/tabulator.css" rel="stylesheet">
</head>
<body>
<div id="example-table"></div>
<script type="text/javascript" src="/node_modules/tabulator-tables/dist/js/tabulator.js"></script>
<script src="./main.js"></script>
</body>
</html>
好的-我添加了一个属性,现在可以使用了(不指定列)。我加了“自动列:真”。它现在将数据和字段名显示为标题。谢谢你的努力。
(我实际上认为“自动列”在默认情况下是“true”。当您定义不同的配置属性时会发生什么,如主页上的示例中所示?Hello Trace-它添加了“分页”按钮,但仍然没有数据。您定义了列吗?我猜您在columns属性配置中定义的键需要与数组对象键相对应?但我也试过这个。。。我得到的只是一张有列名的表格。。。。分页按钮仍然没有数据。当您删除
ajaxResponse
回调时会发生什么?可能有助于您调试未绑定的源代码。
Array(6)
0: {id: "1", firstName: "Lou", lastName: "Pieters", email: "lou@gm.com", phone: "0123456789", …}
1: {id: "2", firstName: "John", lastName: "Snow", email: "john@gm.com", phone: "0129871234", …}
2: {id: "3", firstName: "Buck", lastName: "Rogers", email: "buck@gm.com", phone: "0129986677", …}
3: {id: "4", firstName: "Tom", lastName: "Tom", email: "tom@gm.com", phone: "0129986767", …}
4: {id: "5", firstName: "Dick", lastName: "Richards", email: "dick@gm.com", phone: "0129983344", …}
5: {id: "6", firstName: "Harry", lastName: "Potter", email: "harry@gm.com", phone: "012999900", …}
length: 6
__proto__: Array(0)