2012-08-07 132 views
0

我的表的代碼是這樣的數據表服務器端代碼

<table class="table responsive-table" id="sorting-advanced"> 
       <thead> 
        <tr> 
         <th scope="col">Estado</th>  
         <th scope="col" width="5%" class="align-center hide-on-mobile">Registo</th> 
         <th scope="col" width="5%">Expiração</th> 
         <th scope="col" width="5%" class="align-center hide-on-mobile">Inserção</th> 
         <th scope="col" width="10%">Dominio</th> 
         <th scope="col" width="10%" class="align-center hide-on-mobile">Titular</th> 
         <th scope="col" width="15%" class="align-center hide-on-mobile">Morada Tit.</th> 
         <th scope="col" width="10%">Email Tit.</th> 
         <th scope="col" width="15%" class="align-center hide-on-mobile">Localidade Tit.</th> 
         <th scope="col" width="15%" class="align-center hide-on-mobile">Cód. Postal</th> 
         <th scope="col" class="align-center hide-on-mobile">Nome Ent.</th> 
         <th scope="col" class="align-center hide-on-mobile">Email Ent.</th> 
         <th scope="col" class="align-center hide-on-mobile">Nome Tec.</th> 
         <th scope="col" class="align-center hide-on-mobile">Email Tec.</th> 
         <th scope="col" width="10px" >IP</th> 
         <?php if ($_SESSION['update'] == '1'){echo '<th scope="col" width=20px>Black</th>';} ?> 

        </tr> 
       </thead> 
       <tbody> 

       </tbody> 

       <tfoot> 

       </tfoot> 
      </table> 

我確定年代的代碼...

<script> 

     // Call template init (optional, but faster if called manually) 
     $.template.init(); 


     // Table sort - DataTables 
     var table = $('#sorting-advanced'), 
      tableStyled = false; 

     table.dataTable({ 
      "iCookieDuration": 60*60*2 , 
      "bProcessing": true, 
      "bServerSide": true, 
      "sAjaxSource": "http://pgcc.datasource.pt/beta/listas/whois.php", 
      "sScrollX": "100%", 
      "bScrollCollapse": true, 
      'sPaginationType': 'full_numbers', 
      'oLanguage': { 
        "sProcessing": "A processar...", 
        "sLengthMenu": "Mostrar _MENU_ domínios", 
        "sZeroRecords": "Não foram encontrados resultados", 
        "sInfo":   "Lista de domínios | <button class=\"button compact green-gradient\" onClick=\"javascript: openModal();\">Adicionar</button>",  
        "sInfoEmpty": "Não foram encontrados resultados", 
        "sInfoFiltered": "", 
        "sInfoPostFix": "", 
        "sSearch":  "Procurar:", 
        "sUrl":   "", 
        "oPaginate": { 
         "sFirst": "Primeiro", 
         "sPrevious": "Anterior", 
         "sNext":  "Seguinte", 
         "sLast":  "Último" 
      } 
      }, 
      'sPaginationType': 'full_numbers', 
      'fnDrawCallback': function(oSettings) 
      { 
       // Only run once 
       if (!tableStyled) 
       { 
        table.closest('.dataTables_wrapper').find('.dataTables_length select').addClass('select blue-gradient glossy').styleSelect(); 
        tableStyled = true; 
       } 
      }, 

     }); 
      oTable = $('#sorting-advanced').dataTable(); 

      function fnShowHide(iCol) 
      { 
       /* Get the DataTables object again - this is not a recreation, just a get of the object */ 

       var bVis = oTable.fnSettings().aoColumns[iCol].bVisible; 
       oTable.fnSetColumnVis(iCol, bVis ? false : true); 

      } 
      $(document).ready(function(e) { 
       fnShowHide(1); 
       fnShowHide(3); 
       fnShowHide(5); 
       fnShowHide(6); 
       fnShowHide(8); 
       fnShowHide(9); 
       fnShowHide(10); 
       fnShowHide(11); 
       fnShowHide(12); 
       fnShowHide(13); 
      }); 

    </script> 


    <script> 

     $('#mudar').change(function(){ 
      var valor = $(this).val(); 
      $.post('pesquisar.php',{valor: valor}, function(data){ 
      $('#pesquisa').html(data) 
      }); 
     }); 

    </script> 

而我得到的JSON ...

{"sEcho":0,"iTotalRecords":"2","iTotalDisplayRecords":"2","aaData":[["1","2012-08-06 17:49:05","2012-08-07","2012-08-06","nuno.pt","Nuno Almeida","Rua dos Frades","[email protected]","Seia","1231","Gonçalo Cabral","[email protected]","Datasource","[email protected]","192.168.1.0","1"],["1","2012-08-06 17:49:05","2012-08-07","2012-08-06","rumonet.pt","Nuno Almeida","Rua dos Frades","[email protected]","Seia","1231","Gonçalo Cabral","[email protected]","Datasource","[email protected]","192.168.1.0","2"]]} 

但是,當我加載,表dosn't什麼也沒做...... 它只出現在中間的一個白色正方形,並沒有加載...

如果我改變sAjaxsource到一個文件allraedy工作,它顯示的結果,但輸出JSON格式等於...

ANY1知道爲什麼發生這種情況? :(

回答

1

我能想到的,你發回同一sEcho表創建?從文檔

字符串從客戶端發送sEcho一個不變的sEcho的副本。 此參數的唯一的事情將隨着每次抽籤而變化(這基本上是一個抽籤 count) - 所以重要的是要實現這一點。請注意,爲了安全起見,我們強烈建議您將此 參數「投」到一個整數,以防止跨站點腳本(XSS) 攻擊。

如果你只是總是用同樣的json響應,你應該省略sEcho(並且知道省略它的危險)