我的表格代码是
<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","nuno_ng21@hotmail.com","Seia","1231","Gonçalo Cabral","g.cabral@datasource.pt","Datasource","teste@hotmail.com","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","nuno_ng21@hotmail.com","Seia","1231","Gonçalo Cabral","g.cabral@datasource.pt","Datasource","teste@hotmail.com","192.168.1.0","2"]]}
但是当我加载时,桌子什么都不做...... 它看起来中间只有一个白色方块,没有任何东西加载...
如果我将sAjaxsource更改为allraedy工作的文件,它会显示结果,但输出JSON格式是相等的......
Any1知道为什么会这样吗? :(
答案 0 :(得分:1)
我能想到的唯一一件事,就是你发回桌子创建的相同的sEcho吗?来自文档
string sEcho从客户端发送的未更改的sEcho副本。 此参数将随每次绘制而变化(它基本上是平局 计数) - 因此实施这一点非常重要。请注意它 出于安全原因强烈建议你“投”这个 参数为整数以防止跨站点脚本(XSS) 攻击。
如果你只是总是用相同的json回复,你应该省略sEcho(并且知道省略它的危险)