我需要一些帮助,我已经查看了数据表 api,但我没有做对。
jQuery代码
$(document).ready(function () {
$('#dblist').on('change', function () {
var selected = $("select option:selected").text();
$.ajax({
url: '/php/connect/searchtablequery.php',
type: 'POST',
data: { UserLogin: selected },
success: function (data) {
tablefill(data)
},
error: function (xhr, status, err) { console.log(xhr, status, err); }
});
});
function tablefill(data) {
$('#table_id').dataTable({
"bProcessing": true,
"bDestroy": true,
"sAjaxSource": data,
"sAjaxDataProp": "data.inner",
"aoColumns": [
{ "mDataProp": "calldate" },
{ "mDataProp": "clid" },
{ "mDataProp": "src" },
{ "mDataProp": "dst" },
{ "mDataProp": "dcontext"}],
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "/DataTables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [
"copy", "csv", "xls", "pdf",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": ["csv", "xls", "pdf"]
}
]
}
});
};
});
返回的 JSON 是
{
"0": {
"calldate": "2013-08-14 11:41:28",
"clid": "\"name name\" <1002>",
"src": "1002",
"dst": "8834404",
"dcontext": "from-internal",
"channel": "SIP\/1002-00000000",
"dstchannel": "IAX2\/voipms-6749",
"lastapp": "Dial",
"lastdata": "IAX2\/voipms\/14798834404,300,",
"duration": "7",
"billsec": "0",
"disposition": "NO ANSWER",
"amaflags": "3",
"accountcode": "",
"uniqueid": "1376498488.1",
"userfield": "",
"did": "",
"recordingfile": "",
"cnum": "",
"cnam": "",
"outbound_cnum": "",
"outbound_cnam": "",
"dst_cnam": ""
},"1": {
"calldate": "2013-08-14 11:42:55",
"clid": "\"name name\" <1002>",
"src": "1002",
"dst": "9187755592",
"dcontext": "from-internal",
"channel": "SIP\/1002-00000001",
"dstchannel": "IAX2\/voipms-121",
"lastapp": "Dial",
"lastdata": "IAX2\/voipms\/19187755592,300,",
"duration": "494",
"billsec": "485",
"disposition": "ANSWERED",
"amaflags": "3",
"accountcode": "",
"uniqueid": "1376498575.3",
"userfield": "",
"did": "",
"recordingfile": "",
"cnum": "",
"cnam": "",
"outbound_cnum": "",
"outbound_cnam": "",
"dst_cnam": ""
},