tabulator - 通过 php 加载数据未捕获的 ReferenceError
问题描述
我正在尝试使用 php 文件从数据库加载数据我已经设置了我的 html 页面,如下所示,但是当我运行它时,我收到控制台错误“未捕获的 ReferenceError:$ 未在 tabulatortest.html:38 中定义。
我在网上找到了一个关于如何引用 php 文件的示例,我用它来创建我的 html 和 php 文件。
谁能让我知道我哪里出错了,为什么我会出错?
谢谢我。
<script type="text/javascript">
var table = new Tabulator("#tabulator-example", {
layout: "fitColumns",
responsiveLayout: "hide",
tooltips: true,
addRowPos: "top",
history: true,
pagination: "local",
paginationSize: 10,
movableColumns: true,
resizableRows: true,
initialSort: [{
column: "subsystem",
dir: "asc"
}, ],
columns: [{
title: "Subsystem",
field: "subsystem",
minWidth: 20
},
{
title: "Doc Number",
field: "docNumber",
minWidth: 20
},
{
title: "Description",
field: "docDescription",
minWidth: 20
},
{
title: "Discipline",
field: "Discipline",
minWidth: 20
},
{
title: "Tag Number",
field: "tagNumber",
minWidth: 10
},
],
});
// table.setData(tabledata);
$("#tabulator-example").tabulator("setData", "setData.php");
解决方案
出于某种原因,您似乎在代码中使用了旧的 jQuery 方法:
$("#tabulator-example").tabulator("setData", "setData.php");
您应该改为使用以下内容来设置表中的数据:
table.setData("setData.php");
如果您希望在加载时将数据加载到表中,您可以将 url 直接传递到表定义中的ajaxURL选项中,那么您根本不需要调用setData:
var table = new Tabulator("#tabulator-example", {
layout: "fitColumns",
ajaxURL:"setData.php",
....
查看Ajax 文档以获取有关如何使用此功能的完整信息
推荐阅读
- python - 如何为纵横比 < 1 的图像设置 Matplotlib 颜色条高度
- python - 日期时间索引上的字符串连接
- javascript - 如何使用正则表达式验证密码?
- python - 使用 boto3 的 S3 预签名帖子网址问题
- c++ - 从 fifo_scheduler::process_handle 对象中获取 state_machine 对象
- splunk - 描述一个字段(数据字典而不是统计数据)
- html - 使用 R 加密 HTML 文件?
- mysql - 这个语法对于 mysql 的 python 插入操作是否正确?我收到错误 - TypeError: 'str' object is not callable?
- android - 如何在 android 上查看 ipynb 文件?
- swiftui - 在 SwiftUI 文本字段中更改急救人员的顺序