javascript - DataTables 不能使用 JSON
问题描述
我开始在我的 Codeigniter 项目中使用 DataTable,但我无法使用 JSON 获取数据:如您所见,这是我的 Javascript 代码和下面给出的 JSON 数据结构:
$('#sms_tab').DataTable({
"ajax" : "http://localhost/p/contact/sms",
"columns" : [
{"result" : "texto_id"},
{"result" : "texto_body"},
{"result" : "texto_date"},
{"result" : "texto_time"},
{"result" : "texto_type"},
{"result" : "state"}
]
});
JSON数据结构:
{
"site":"http:\/\/localhost\/p\/",
"page":"contact\/sms",
"jsFunction":"sms",
"baseurl":"http:\/\/localhost\/p\/",
"result":[{
"texto_id":"1",
"texto_body":"hello world",
"texto_date":"2018-08-01",
"texto_time":"04:27:07",
"related_contacts":"1",
"related_users":"1",
"texto_type":"OUT",
"state":"1"
},
{
"texto_id":"2",
"texto_body":"test",
"texto_date":"2018-08-09",
"texto_time":"05:18:22",
"related_contacts":"1",
"related_users":"1",
"texto_type":"IN",
"state":"1"
},
{
"texto_id":"3",
"texto_body":"hhhh",
"texto_date":"2018-08-09",
"texto_time":"10:28:10",
"related_contacts":"1",
"related_users":"1",
"texto_type":"OUT",
"state":"1"
},
解决方案
推荐阅读
- javascript - 如何更改本机反应中的每个图标名称
- c++ - 如何有效地在 googletest 中组织单元测试
- apache-spark - PySpark 数据框条件按窗口/滞后
- google-chrome - 查看源代码开始显示1行中的所有代码,如何更改?
- demandware - 如何使用 SFRA 创建站点,但名称和 ID 将是我的自定义名称和 ID
- css - 如何使我的 :active 伪元素工作?
- python - AI 100 测试人脸检测 API 练习
- qt - 如何在其他类中获取应用程序的QML引擎
- r - 如何用循环的输出覆盖循环中的列列表?
- c++ - UDP 多播不适用于 linux Debian