0
私はちょうどdatatablesを使い始めました。この例ではdatatables docsから作業していましたが、表示するデータを取得できません。 これは.html file
次のとおりです。データテーブルにデータを表示するにはどうすればよいですか?
<html>
<head>
<title>data</title>
<script href="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script href="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable({
"ajax": 'arrays.txt'
});
});
</script>
</body>
</html>
、これはarrays.txt
ファイルです:
{
"data": [
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
]
]
}
問題は何もデータがデータテーブルに表示されていないということです。
デバッグのためにテーブルの代わりに 'PRE'に入れてみてください。 'arrays.txt'は閉じた中括弧の前に閉じ角括弧がありません! – neuhaus
コンソールにエラーがありますか? –
@EliasSoares私はこれを取得します: 'Uncaught ReferenceError:jQueryが定義されていません' – annie