javascript - 使用数据表jquery在codeigniter中"Undefined table data"

标签 javascript jquery codeigniter datatable

我一直在尝试将 datatables jquery 插件与 codeigniter 一起使用,但仍然没有运气。 我是这个 api 的新手。 (请不要使用 ignitedTables,只需使用 dataTables jquery 插件)。

View 返回:

未定义的表格数据

请参阅下面的 MVC:

查看(脚本所在的位置)

<script type="text/javascript">
    $(document).ready(function() {
var oTable = $('#big_table').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "<?php echo site_url('home/calendarListAll/') ?>",
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "iDisplayStart ":20,
            "fnInitComplete": function() {
            //oTable.fnAdjustColumnSizing();
     },
            'fnServerData': function(sSource, aoData, fnCallback)
        {
          $.ajax
          ({
            'dataType': 'json',
            'type'    : 'POST',
            'url'     : sSource,
            'data'    : aoData,
            'success' : fnCallback
          });
        }
        } );
    } );
    </script>

    <html>
    <?php echo $this->table->generate(); ?> //this returns "Undefined table data"
    </html>    

Controller

function __construct()
{
 parent::__construct();
  $this->load->library('Datatables');
  $this->load->library('table');
  $this->load->database();
  $this->load->helper('url');
  $this->load->helper('form');
  $this->load->helper('html');
}

public function calendarListAll()
{
    $this->load->model('counselor');
    $result = $this->counselor->getCalendar();
    echo $this->datatables->generate($result);
}  

型号

function getCalendar() // get referred_appointments
{

    $counselor_id = $this->session->userdata('counselor_id');

    $query = $this->db->select ('s.first_name as student_fname, s.last_name as student_lname, s.middle_name as student_mname, e.first_name, e.last_name, e.middle_name, re.*, r.student_id, i.*, e.*')
    ->from ('referral as r, student_course_record as scr, curriculum as c, referred_appointment as re, degree as d, course as cc, counselor as ccc,  issue as i, student as s, employee as e')
    ->where ('r.student_id = scr.student_id')
    ->where ('scr.curr_id = c.curr_id')
    ->where ('c.degree_id = d.degree_id')
    ->where ('d.course_id = cc.course_id')
    ->where ('cc.counselor_id = ccc.counselor_id')
    ->where ('r.issue_id = i.issue_id')
    ->where ('r.student_id = s.student_id')
    ->where ('re.referral_id = r.referral_id')
    ->where ('r.employee_id = e.employee_id')
    ->where ('ccc.counselor_id', $counselor_id)
    ->where ('re.status != "C"');
    $ret = $query->get()->result();
    return $ret;

}

最佳答案

使用对您有帮助吗CI Help

$tmpl = array ('table_open' => '<table id="big_table">');
$this->table->set_template($tmpl);

关于javascript - 使用数据表jquery在codeigniter中"Undefined table data",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27565201/

相关文章:

javascript - 输入文本未经 codeigniter 验证

Jquery- 添加 css onclick 仅在第一次点击时起作用

javascript - 具有特定类的多个html表格单元格的JQuery总和

php - Codeigniter 中函数调用时出现 500 错误

javascript - 在 AngularJS 中使用 $http 服务时的变量范围

javascript - 如何使用 jQuery 获取选定的单选按钮标签文本

javascript - "StringQueryOperatorInput"类型是什么?我怎样才能摆脱这个恼人的 graphql 错误?

jquery - 循环到第一张幻灯片 flexslider

php - codeigniter 将日期插入通过 post 方法发送的数据库中

javascript - javascript 文件中的 Codeigniter( Controller )文件路径