我只是想用下面的JSON对象查询的数据表的一个例子...
[{"firstName":"pom",
"lastName":"sdfpom",
"email":null,
"password":"cfe9a43acec0a35f903bc2d646ce8e58b5ef6b67",
"username":"Dave",
"access":null,
"id":1},
{"firstName":"FirstName",
"lastName":"LastName",
"email":null,
"password":"8d60258ef3ae1b8eae67e9298f15edf5c6e05dfe",
"username":"Username",
"access":null,
"id":2}]
这回在下面的可变数据...
<script>
$(document).ready(function() {
$.getJSON('userManagement/getAllUsers', function(data) {
$('#table').dataTable( {
"sAjaxSource": data
});
});
});
</script>
<table id="table">
<thead>
<tr>
<th>firstName</th>
<th>lastName</th>
<th>email</th>
<th>password</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
<td>etc</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
<td>etc</td>
</tr>
</tbody>
</table>
现在,JSON似乎是有效的,而当我为实例做任何事情与它的jQuery中使用它,它工作正常,但数据表只是不正确地呈现在所有。 是不是有什么毛病我使用的JavaScript?