2014-04-22 27 views
6

Ver oluşturucu 1,10 ile dom oluşturulmuş tablo. Ajax yanıtı içinde yeni bir veri satırı eklemeyi deniyorum ama hiçbir şey olmuyor. Aynı kod kendi başına (ajax yok) mükemmel çalışıyor. Evet, response.success 'true' geri dönüyor.datatables 1.10 add.row() ajax yanıtı içinde çalışmaz

// Bu çalışır ve tabloya yeni bir satır ekler

$('#test').on('click', function() { 
    dt.row.add([ 
     'td0', 
     'td1', 
     'td2', 
     'td3' 
    ]).draw(); 
}); 

// ... kod bir ajax yanıtı içindeki çalışmıyor aynı

Eklemek çağırdıktan sonra
$('#dtCreate').on('click', function() { 

    $.ajax({ 
     type: 'post', 
     url: '/test/process/p_db_create.php' 
    }).done(function (response) { 

     //double check response 
     console.log(response); 

     if (response.success) 
     { 
      //add the row since this is not serverside 
      dt.row.add([ 
       'td0', 
       'td1', 
       'td2', 
       'td3' 
      ]).draw(); 
       ...more code below... 
+0

Bunu bulamadınız mı? Aynı konuya koşuyorum. –

cevap

0

() .çekmek(); Tabloyu yeniden başlatarak - dt.dataTable();

1

td, DataTable() dataTable() tarafından başlatılmalıdır. Bu soruna rastladım ve birkaç saatimi harcadım.

İlgili konular