DataTables无效的JSON响应

时间:2017-08-14 16:18:21

标签: datatables datatables-1.10

我在使用DataTables时遇到了一些问题。

我试图使用服务器端脚本在项目中加快数据加载速度,但我一直都会遇到错误。

当我加载页面时,我得到的第一个错误是:

@Override
public final void onNext(PostResponse postResponse) {
 if (postResponse != null) {
  // TODO: Some object is returned but its properties are null
  Log.e("RetrofitService", "Objects successfully added to RecyclerView Adapter.");
  Log.e("RetrofitService", "Returned objects: " + postResponse.getResults());
  Log.e("RetrofitService", "Text " + postResponse.getResults().get(0).getText());

  mCardAdapter.addData(postResponse);
  //
 } else {
  Log.e("RetrofitService", "Object returned is null.");
 }

}

当我在搜索字段中输入任何内容时,我会在日志和标签中找到相同的错误" Network"我收到以下错误:

datatables.min.js:86 Uncaught Error: DataTables warning: table id=lista_pedidos - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
at K (datatables.min.js:86)
at Object.error (datatables.min.js:48)
at i (jquery.js:2)
at Object.fireWith [as rejectWith] (jquery.js:2)
at A (jquery.js:4)
at XMLHttpRequest.<anonymous> (jquery.js:4)

这些是我的脚本:

1)初始化DataTables:

<br />
<b>Notice</b>: Undefined offset: 0 in <b>C:\wamp64\www\prevmais\sistema\app\server\ssp.class.php</b> on line <b>116</b><br />
<br />
<b>Notice</b>: Undefined offset: 0 in <b>C:\wamp64\www\prevmais\sistema\app\server\ssp.class.php</b> on line <b>162</b><br />
<br />
<b>Notice</b>: Undefined offset: 1 in <b>C:\wamp64\www\prevmais\sistema\app\server\ssp.class.php</b> on line <b>162</b><br />
<br />
<b>Notice</b>: Undefined offset: 0 in <b>C:\wamp64\www\prevmais\sistema\app\server\ssp.class.php</b> on line <b>176</b><br />
<br />
<b>Notice</b>: Undefined offset: 1 in <b>C:\wamp64\www\prevmais\sistema\app\server\ssp.class.php</b> on line <b>176</b><br />
{"error":"An SQL error occurred: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 100' at line 5"}

2)服务器端脚本:

$(document).ready(function() {

$.fn.dataTable.ext.errMode = 'throw';

$('#lista_pedidos').DataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": {
        url: "/app/server/server_side.php",
        dataType: 'JSON'
    }
});

我做错了什么?

0 个答案:

没有答案