2017-01-10 51 views
1

需要幫助,我有3個AJAX其中 - 數據從阿賈克斯有按鈕,如果點擊會顯示AJAX乙 - 從阿賈克斯B數據有按鈕,如果點擊會顯示AJAXÇ 問題如何AJAX負載之前清除數據表從另一個AJAX

<script type="text/javascript"> 
var save_method; //for save method string 
var table; //for ajax A 
var table2; // for ajax B 
var table3; // for ajax C 
var base_url = '<?php echo base_url()?>'; 
    // table2 = $('#table_id2').clear(); 
    // table2 = $('#table_id2').rows.add(response.data); 
    // table2 = $('#table_id2').draw(); 
    $(document).ready(function() { 
    //datatables 
    table = $('#table_id').DataTable({   
     "lengthMenu": [[5, 10, 25, -1], [5, 10, 25, "All"]], 
     "deferLoading": 0, 
     "processing": true, //Feature control the processing indicator. 
     "language": { 
      "processing": "<span><img src='images/Preloader_3.gif'/></span>" 
      }, // you can put text or html here in the language.processing setting.    
     "serverSide": true, //Feature control DataTables' server-side processing mode. 
     "order": [], //Initial no order. 
     // Load data for the table's content from an Ajax source 
     "ajax": { 
      "url": "<?php echo base_url('infoemployee/ajax_list')?>",    
      "type": "POST", 
     },  
     //Set column definition initialisation properties. 
     "columnDefs": [ 
      { 
       "targets": [ -1 ], //last column 
       "orderable": false, //set not orderable 
      },     
     ], 
    }); }); 

回答

2

在此之後:如果我在尋找一個新的搜索從阿賈克斯乙 數據還是老如何阿賈克斯之前清除從阿賈克斯二旦C數據負載 此我對阿賈克斯的代碼是在從阿賈克斯的DataTable區塊

"ajax": { 
     "url": "<?php echo base_url('infoemployee/ajax_list')?>",    
     "type": "POST", 
    }, 

添加這上面一行

"destroy" : true, 
+0

喜伊萬,什麼意思「消滅」:真實,阿賈克斯還是阿賈克斯B' –

+0

這兩個,你必須嘗試瞭解 –

+0

感謝ivan它的作品添加到我所有的ajax代碼 –