2016-04-22 85 views
0
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:jQuery的阿賈克斯的DataTable

<!-- 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> 

我使用的數據表,但沒有數據在數據表中添加。總是寫道「沒有數據在表中可用」 我檢查的案件有數據和我$(".own_cases_table").DataTable();,但沒有任何改變。

如何將數據添加到我的表中?

我試着用ownDataTable.row.add(),但同樣的結果發生

+0

待辦事項共享相同.. – Rayon

+0

服務器的小提琴在本地主機 – Ozgun

+0

您可以使用響應作爲一個靜態的對象! – Rayon

回答