这是与 HTML 文件位于同一目录中的 feature-table.JSON:
[
{
"band": "Weezer",
"song": "El Scorcho"
},
{
"band": "Chevelle",
"song": "Family System"
}
]
这是我的 HTML 文件:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery-1.11.1.min.js">
<script type="text/javascript" src="jquery.dynatable.js"></script>
<script type="text/javascript">
$.getJSON("feature-table.JSON", function(data) {
alert(data);
$("#feature-table").dynatable({
dataset: {
records: data
}
});
});
</script>
</head>
<body>
<table id="feature-table">
<thead>
<th>band</th>
<th>song</th>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
警报会弹出正确的 JSON 数据,所以我知道它正在找到它。我已经尝试过:jQuery 的第 2 版,上传和使用 js 文件的 URL 以确保文件位于正确的位置,$.ajax 但是在读取Load remote JSON from Dynatable后的 $.getJSON以及其他各种东西。我没主意了。我在看什么?