我正在使用带有Ajax的jQuery DataTable来显示数据。它显示数据但排序和搜索不起作用。当我点击任何一列对数据进行排序时,它会显示“正在处理...”并且没有任何反应。
这是我的代码:
<div class="row">
<div id="flux-col-1" class="col-md-12">
<div class="body" id="">
<div class="row">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>From</th>
<th>Object</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "mails",
"columns": [
{ "data": "from" },
{ "data": "object" },
{ "data": "created" }
]
} );
} );
</script>
答案 0 :(得分:0)
试试这个并更改你的“ajax”:“mails”,你的网址就像这样
<div class="row">
<div id="flux-col-1" class="col-md-12">
<div class="body" id="">
<div class="row">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>From</th>
<th>Object</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "<?php echo site_url('mails/ajax_list_mail')?>",
"columns": [
{ "data": "from" },
{ "data": "object" },
{ "data": "created" }
]
} );
} );
</script>