我一直在努力让DataTables与我现有的Ajax搜索功能一起工作 – 它本身就可以工作.
我有以下代码:
$('#SearchResults').dataTable({ "bProcessing": true,"bServerSide": true,"bRetrieve": true,"sAjaxSource": "process.PHP?action=searchArtifact","fnServerData": function (sSource,aoData,fnCallback){ aoData.push({ "name": "searchName","value": $('#ArtifactSearch').attr('value') }); $.ajax({ "dataType": "json","type": "POST","url": sSource,"data": aoData,"success": fnCallback }); } });
PHP返回一个有效的JSON对象(使用JSON_FORCE_OBJECT):
{"0":{"ARTIFACT_ID":"4E2FE3BCE356C","ARTIFACT_NAME":"123","ARTIFACT_TYPE":"UI","ARTIFACT_LABEL":"Test_Int_EAS_123","ARTIFACT_LOCATION":"Int","ARTIFACT_DOMAIN":"ABC","ARTIFACT_AUTHOR":null,"REGISTERED_EMAIL":"test@test.com","REGISTERED_DATE":"27-07-2011","REGISTERED_TIME":"11:09:00"}
我可以在FireBug中看到这一切很好,但我的空表没有填充这些数据.
有任何想法吗?
@Kyle:呃 – 这就是它.我猜我没有?这是我与DataTables的第一次尝试(斗争),我只是从文档中复制:http://www.datatables.net/usage/callbacks#fnServerData
@MarcB:补充说 – 但仍然没有显示数据.谢谢您的帮助