将DataTable与Codeigniter一起使用时,它显示的是处理而不是显示数据

将DataTable与Codeigniter一起使用时,它显示的是处理而不是显示数据

问题描述:

I'm trying to use DataTables with CodeIgniter.

Here is what I have done so Far.

1) Added the IgnitedDatatables Library to my library and called it to my datatables controller,

$this->load->library('Datatables.php');

2) View

<table id="ManageForms" class="table table-bordered table-condensed table-hover table-striped">
    <thead>
        <tr>
            <th>Form Name</th>
            <th>Browser</th>
            <th>Platform(s)</th>
            <th>Engine version</th>
            <th>CSS grade</th>
        </tr>
    </thead>
</table>

<script>
    $(document).ready(function() {
        $('#ManageForms').dataTable({
            "processing":true,
            "serverSide":true,
            "bProcessing":true,
            "sServerMethod": "POST",
            "sAjaxSource": "{{base_url()}}admin/configurations/listForms_DT/",
            "iDisplayLength": 10,
            "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
            "aaSorting": [[0, 'asc']],
            "aoColumns": [
                { "bVisible": true, "bSearchable": true, "bSortable": true },
                { "bVisible": true, "bSearchable": true, "bSortable": true },
                { "bVisible": true, "bSearchable": true, "bSortable": true }
            ],
            "columns": [
                { "data": "FormName" }
            ],
            'fnServerData'   : function(sSource, aoData, fnCallback){
                $.ajax ({
                    'dataType': 'json',
                    'type'    : 'POST',
                    'url'     : sSource,
                    'data'    : aoData,
                    'success' : fnCallback
                }); //end of ajax
            }

        });
    });
</script>

3) Data in Json Return in this Form from the Path:

 {"data_DT":[{"FormID":"1","FormName":"Dashboard","FormPath":"#","FormCIPath":"admin\/dashboard\/System","IsMenuLink":"1","MenuID":"1","FormRoleID":"1","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"2","FormName":"Dashboard","FormPath":"#","FormCIPath":"admin\/dashboard\/Users","IsMenuLink":"1","MenuID":"2","FormRoleID":"2","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"3","FormName":"Residensials","FormPath":"#","FormCIPath":"#","IsMenuLink":"1","MenuID":"3","FormRoleID":"3","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"6","FormName":"Configuration","FormPath":"#","FormCIPath":"#","IsMenuLink":"1","MenuID":"6","FormRoleID":"4","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"7","FormName":"ManageForms","FormPath":"#","FormCIPath":"admin\/configurations\/ManageForms","IsMenuLink":"1","MenuID":"7","FormRoleID":"5","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"}]}

Now the Problem is that my DataTables instead of showing days, shows Processing??

I am not sure where did i go wrong, please if anyone can fix the issue or redirect me what did i do wrong?

This message means, DataTable is unable to read properly your data.

Using default settings, your ajax request must return data into aaData object.