前端JS調用代碼
$('#table_id').DataTable({ "language": { "sPRocessing": "處理中...", "sLengthMenu": "顯示 _MENU_ 項結果", "sZeroRecords": "沒有匹配結果", "sInfo": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項", "sInfoEmpty": "共0條記錄", "sInfoFiltered": "", "sInfoPostFix": "", "sSearch": "", "sSearchPlaceholder":'請輸入ID或者標題', "sUrl": "", "sEmptyTable": "表中數據為空", "sLoadingRecords": "載入中...", "sInfoThousands": ",", "oPaginate": { "sFirst": "首頁", "sPrevious": "上頁", "sNext": "下頁", "sLast": "末頁" }, }, bServerSide:true, Ajax:{ url:"{:U('signin/record')}", type:'post', dataSrc:'list' }, "columns":[{"width":"50px",'data':'userId','orderable':false}, {'width':'100px','data':'sign_time','orderable':false}, {'width':'60','data':'count'}, {'width':'50','data':'round'}, {'width':'150','data':'prize_status_label'}, ], "pageLength": 20, "lengthChange": false, "order": [[ 0, 'desc' ]], "dom": '<"toolbar">frt分頁配置url:請求地址
type:請求類型
dataSrc:表示的是請求回來的數據對象中 哪個屬性為列表數據 若值為list 則如 {recordsTotal:200,recordsFiltered:200,draw:'xxx','list:'[,,,,,,,,,,,,]}
服務端數據構造就如上述dataSrc配置數據格式即可
服務端返回的數據中 有一個draw屬性 該值是為了防止xss攻擊 前端傳入什么 后端就返回什么
新聞熱點
疑難解答