I'm use DataTable to display my data by serverSide mode and ajax.
Everything is okay, but pagination doesn't work.
You can review the codes as follow:
HTML:
<table id="table" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<td>ID</td>
<td>First name</td>
<td>Last name</td>
<td>Email</td>
</tr>
</thead>
<tbody></tbody>
</table>
Javascript:
$(document).ready(function () {
$('#table').DataTable({
serverSide: true,
ajax: {
url: '<?php echo base_url(); ?>folder/class/method'
},
processing: true,
scrollY: 370,
paging: true,
bJQueryUI: true
});
});
The data that returned from server ( JSON
) as following:
{
"draw": 1,
"recordsTotal": 1208,
"recordsFiltered": 10,
"data": [
["1", "pando", "rewar", "pando@hotmail.com"],
["2", "chori", "raon", "m_chori@hotmail.com"],
["3", "Gorbat", "horiz", "horiz_555@yahoo.com"],
["4", "martin", "sokza", "martin_em5@gmail.com"],
["5", "dooz", "solda", "solda_m@gmail.com"],
["6", "maro", "meza", "r_meza@hotmail.com"],
["7", "nod", "ion", "nod_eam@yahoo.com"],
["8", "kaz", "loob", "kaz_007@hotmail.com"],
["9", "Barbara", "Elliott", "adipiscing@nonmassanon.org"],
["10", "Kendall", "Nathaniel", "ante.blandit@scelerisque.edu"]
]
}
All components of DataTable work fine, but the pagination not.
Parameter recordsFiltered
must be equal to recordsTotal
unless user performed a search. See manual for more information on sent and received parameters.
Also make sure you're returning the same value of draw
parameter in the response. In JSON response value of draw
parameter must match value of draw
parameter from the request .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.