简体   繁体   中英

Server Side Processing at DataTable

I am using DataTable at server side processing. Here table shows no Datas in table

var DataTableApp = $('#DataTableApp').dataTable({
            "sAjaxSource": "php/getAppDetails.php",
            "bRetrieve":true,
            "bDestroy":true,
            "bServerSide": true,
            "fnServerParams": function ( aoData ) {
                var imei_apps = document.getElementById('imei').value;
                console.log(imei_apps);
                aoData.push( { "name": "imei", "value": imei_apps } );
            },

            "aoColumns": [{
                "mData": "appName",             
            }, {
                "mData": "appId",
            }, {
                "mData": "versionInstalled"
            }, {
                "mData": "appSize",
            }, {
                "mData":"dataSize",
            },{
                "mData": "appType",
            },{
                "mData":"installedLocation",
            },{
                "mData": "appType",
            }],
        });

What is the mistake in that code. I cant find the solutions

Try building your response similar to this:

{"sEcho": $sEcho, "iTotalRecords": $total, "iTotalDisplayRecords": $filtered,
 "aaData": [
     [$row1_col1, $row1_col2, $row1_col3],
     [$row2_col1, $row2_col2, $row2_col3]
  ]}

In PHP it would look like this:

$json = new stdClass;
$json->aaData = array();
$json->aaData[] = array($row1_col1, $row1_col2, $row1_col3);
$json->aaData[] = array($row2_col1, $row2_col2, $row2_col3);

$encoded_json = json_encode($json);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM