weixin_33701617 2016-04-22 07:00 采纳率: 0%
浏览 45

jQuery Ajax数据表

var ownDataTable = $(".own_cases_table").dataTable();

$.ajax({
        url : "api/v1/cases/"+encodeURIComponent(uid)+"/active",
        type : "get",
        headers : { "Authorization" : api_key },
        dataType : "json",
        success : function(response) {
            if (response.error) {

            } else {
                var cases = response.cases;
                ownDataTable.fnClearTable();
                for (var i = 0; i < cases.length; i++) {
                    console.log(cases[i].case_name);
                    ownDataTable.fnAddData([ cases[i].case_name, cases[i].slide_img, 'Daha Fazla', 'action' ]);
                }
            }
        }
    });

HTML :

<!-- TABLE FOR MOBILE START -->
              <table class="table mb30 own_cases_table">
                <thead>
                  <tr>
                    <th><?php echo _("Olgu"); ?></th>
                    <th><?php echo _("Dijital Slide"); ?></th>
                    <th><?php echo _("Daha Fazla"); ?></th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
              </div>
             <!-- TABLE FOR MOBILE END -->

          <div class="table-responsive hidden-xs hidden-sm">
          <table class="table own_cases_table">
              <thead>
                 <tr>
                    <th><?php echo _("Olgu"); ?></th>
                    <th><?php echo _("Dijital Slide"); ?></th>
                    <th><?php echo _("Daha Fazla"); ?></th>
                    <th></th>
                 </tr>
              </thead>
              <tbody>                 
              </tbody>
           </table>

i am using datatables but no data is added in datatables. Always writes "No data avaliable in table" i checked cases has data and i $(".own_cases_table").DataTable(); but nothing changed.

How i can add data into my tables ?

I tried with ownDataTable.row.add() but same result occured

  • 写回答

1条回答 默认 最新

  • weixin_33728708 2016-04-22 07:37
    关注

    You can use this to initalize datatable.

    $('#example').DataTable( { "processing": true, "serverSide": true, "ajax": "../server_side/scripts/server_processing.php" } );

    from https://datatables.net/examples/data_sources/server_side.html

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料