jquery - 成功响应的表中没有可用数据
问题描述
我检查了 Firefox 中的网络监视器,它说我成功获取了 Json 数据。从弹簧指南来看,它应该是:
{
"id": 37658,
"content": "Hello, World!"
}
但我得到no data available in table
了我的数据表。我错过了什么吗?
Plunker的完整代码
桌子:
<table id="example" class="display" style="width: 100%">
<thead>
<tr>
</tr>
</thead>
</table>
脚本:
<script>
$(document).ready(function() {
$('#example').DataTable({
"ajax" : {
"dataType" : 'json',
"contentType" : "application/json; charset=utf-8",
"url" : "http://rest-service.guides.spring.io/greeting",
"dataSrc" : "",
},
columns: [{
data: "id",
name: "id",
title: "Id"
},
{
data: "content",
name: "content",
title: "content"
}]
});
});
</script>
解决方案
我的列语法不正确。它通过一些附加参数固定在下面:
<script>
$(document).ready(function() {
$('#example').DataTable({
"ajax" : {
"dataType" : 'json',
"contentType" : "application/json; charset=utf-8",
"url" : "http://rest-service.guides.spring.io/greeting",
"dataSrc" : "",
},
"columns": [
{ "data": "id"},
{ "data": "content"}
]
});
});
</script>
推荐阅读
- https - Android 应用程序一旦连接到 Fiddler,就会失去互联网连接
- python - 如何使这个乐透计划可重复
- raku - Perl6:如何从命令行读取混合参数?
- python - 使用 holt-winters 模型进行预测
- python-3.x - 如何将每个整数“一一”相乘并“按渐进顺序”显示结果,直到所有整数相乘得出整体乘积
- plugins - Visual Studio 代码扩展变量
- python - AttributeError:“模块”对象没有属性“液晶显示器”
- rest - WooCommerce rest api包括参数不获取可变产品的变化
- scala - 在 Scala 中计算素数流的代码
- java - 在java中重新分配其复制引用时更改原始对象