php - Json with datatable -


i need this, have reviewed datatable api , not getting right.

jquery code

$(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"]                 }             ]         }     }); }; 

});

the json returning

{     "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": ""     }, 

try changing:

"sajaxsource": data, 

to this:

"sajaxsource": '/php/connect/searchtablequery.php', 

try adding:

"bserverside": true, 

edit 1:

$(document).ready( function() {   $('#example').datatable( {     "sajaxsource": "http://www.sprymedia.co.uk/datatables/json.php"   } ); } ) 

ref. http://datatables.net/usage/options

edit 2:

as shown in jsfiddle http://jsfiddle.net/hedvf/667/ json different mine. don't know if makes difference, try changing it. here mine:

{     "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": "" },{     "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": "" } 

here yours:

"0":{     "calldate":"2013-08-14 11:41:28",     "clid":"\"ryan merritt\" <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":"\"ryan merritt\" <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":"" }, 

notice how yours has keys of "0" , "1." try removing , making json php file more mine.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -