【发布时间】:2016-05-02 23:33:44
【问题描述】:
我需要从 AJAX 向 jQuery DataTable 中插入行。在 AJAX 中,当我对我的 mySql 数据库进行查询时,我调用了一个 PHP 文件,但我只在行中显示了一个字符。是因为返回的格式不正确,但是我无法解析正确的格式。
$query = "..myquery..";
if ($row = mysql_fetch_array($sql)) {
do {
$arr []= $row['name'];
} while ($row = mysql_fetch_array($sql));
echo json_encode($arr); // Here I tried return array without json_encode and a lot of things...
}
我知道用.DataTable().row.add() 添加行的格式如下,但我没有得到所需的格式。
[["Element software"], ["Software dist"],["Global envir"], ["Software"], ["Software list"]]
如何在回显中获取此格式以返回此内容? 谢谢!
【问题讨论】:
标签: php jquery mysql ajax datatables