dongqiao8421 2013-08-25 13:49
浏览 31

数据表未加载

I am trying to using datatables Jquery plugin in codeingiter but its not working please help me to debug

Heres my controller where I am calling my view:

  public function show_all_merchants()
        {
                $data["query"]= $this->details_model->get_mids();

                $this->load->view('show_merchants_view',$data);

        }

Heres my view:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script src="<?php echo base_url(); ?>assets/js/jquery.dataTables.js"></script>


<script>

    $(document).ready(function()
            {
              $('#example').dataTable
              ({
                'bProcessing'    : true,
                'bServerSide'    : true,
                'sAjaxSource'    : 'show_merchant_details',
                'iDisplayStart'  : 0,
                  'fnServerData': function(sSource, aoData, fnCallback)
        {

         $.ajax 
          ({
            'dataType': 'json',
            'type'    : 'POST',
             'url'    : sSource,
             'data'  : aoData,
             'success' : fnCallback,
            'cache'   : false
          });
        }

              });
            });


    </script>


 <table cellpadding="0" cellspacing="0" border="0" id="example">
                                  <thead>
                                    <tr>
                                      <th width="20%">ID</th>
                                      <th width="25%">First Name</th>
                                      <th width="15%">Last Name</th>
                                      <th width="25%">Email</th>
                                        <th></th>
                                        <th></th>
                                    </tr>

                                  </thead>
                                  <tbody>
                                    <tr>
                                      <td colspan="5">Loading data from server</td>
                                    </tr>
                                  </tbody>

 </table>

and heres my controller where I am loading the data Here I am loading data tables library:

 function show_merchant_details()
    {
                 $this->datatables
                 ->select('mid, merchant_name, merchant_link,merchant_contact')
                 ->from('merchants')
                 ->add_column('edit', '<a href="store/update/$1" title="Edit">Edit</a>', 'id')
                 ->add_column('delete', '<a href="store/delete/$1" title="Delete">Delete</a>', 'id');

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

    }

Friends show_merchant_details() is wrking properly as i am able to see the output
In the view page I am able to see it like Loading data from server ...... (dats it)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大