Getting minimal server side processing working with php/codeigniter

Getting minimal server side processing working with php/codeigniter

kckc Posts: 14Questions: 4Answers: 0

I'm working with the jquery datatables plugin 1.94 and codeigniter , while trying to get basic server side processing working. The data is not loading initially:
I'm working with the jquery datatables plugin 1.94 and codeigniter , while trying to get basic server side processing working. The data is not loading initially:

The initial request is :

http://localhost/b1/datatable_controller/datatable?sEcho=1&iColumns=4&sColumns=&iDisplayStart=0&iDisplayLength=10&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&_=1407515220536

In firebug there are no errors and the following JSON is returned:

{"sEcho":0,"iTotalRecords":3,"iTotalDisplayRecords":3,"aaData":[["2","<047d7bf1665e40753c04fd394d72@google.com>","Delivery Status Notification (Failure)","2014-07-02 19:34:17"],["3","","Flying the red, white and blue on YouTube","2014-07-03 19:01:21"],["4","<047d7bf1665e9934f004fd640c89@google.com>","Delivery Status Notification (Failure)","2014-07-04 22:34:16"]],"sColumns":"id,message_id,subject,date"}

I notice that the sEcho is different . The number of records (3) is correct. The table itself its empty.

How can I fix this?

My controller:

    function index2()
    {  
        $fulltable=R::getAll( 'select * from imap' );
        $keys=  array_keys($fulltable[0]);
        $this->load->view('serversidetestviewbasic',array('fulltable'=>$fulltable, 'keys'=>$keys));

    }
    //function to handle callbacks
    function datatable()
{

    $fulltable=R::getAll( 'select * from imap' );
    $keys=  array_keys($fulltable[0]);
            $keystring = implode(",", $keys);
    $this->datatables->select($keystring)->from('imap');

    echo $this->datatables->generate();

}   

My view:

   <html> 
  <head> 
      <base href="<?=base_url();?>">


    <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>

  </head> 
  <body> 

    <table id="myDataTable">
        <thead>
            <tr>

                <?php foreach($keys as $key): ?>
                <th><?php echo $key; ?></th>
                <?php endforeach; ?>


            </tr>

        </thead>      
        <tbody>



                  </tbody>
        </table>
$(document).ready(function() { $('#myDataTable').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": 'datatable_controller/datatable', } ); } );
  </body> 
 </html> 

Answers

This discussion has been closed.