我正在使用数据表ajax,但分页,搜索栏,长度菜单不起作用

时间:2018-01-06 04:53:20

标签: php ajax datatable

我正在使用Data Table AJAX,从JSON获取数据,数据表分页,搜索栏无法正常工作。这是我的代码。从JSON中的(progress_play_transactions.php)文件中获取数据

progress_play_transactions.php(代码)

$data[] = array(
    "OriginalTransactionID" => "$OriginalTransactionID",
    "PlayerID" => "$PlayerID",
    "CasinoName" => "$CasinoName",
    "TransactionDate" => "$TransactionDate",
    "TransactionType" => "$TransactionType",
    "Currency" => "$Currency",
    "CurrencySymbol" => "$CurrencySymbol",
    "TransactionOriginalAmount" => "$TransactionOriginalAmount",
    "TransactionDetails" => "$TransactionDetails",
    "Status" => "$Status"
    );}
    echo json_encode(array("result"=>$data,
        "recordsTotal" => intval( $totalrecords ),  
        "recordsFiltered" => intval($totalrecords)
    )
);

progress_play.php(代码)

$(document).ready(function () {
    $('#examples').DataTable({
        "bProcessing": true,
        "serverSide": true,
        "ajax": {
            "url": "progress_play_transactions.php",
            "type": "json",
            "dataSrc": "result"
        },
        "columns": [
            { "data": "OriginalTransactionID" },
            { "data": "PlayerID" },
            { "data": "CasinoName" },
            { "data": "TransactionDate" },
            { "data": "TransactionType" },
            { "data": "Currency" },
            { "data": "CurrencySymbol" },
            { "data": "TransactionOriginalAmount" },
            { "data": "TransactionDetails" },
            { "data": "Status" }
        ],
    });
});

0 个答案:

没有答案