Why i can't load my datatable with my json?
Why i can't load my datatable with my json?
Im using datatable combine with laravel at first, and then it start to take more time when it load more than 1000 data. Im deciding to change my datatable load with json with hoping it will run faster, it was my first time loading datatable with json and I don't know how to solve this issue. I've been trying to load an array of objects but it doesn't work. I really appreciate if anybody could help me. Post my code below.
this is my HTML look like :
<table class="table datatable-basic table-bordered" id="gudang-table" width="100%">
<thead>
<tr>
<th>No</th>
<th>Kode Gudang</th>
<th>Nama Gudang</th>
<th>Port</th>
<th>Alamat</th>
<th class="text-center">Kota</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
this is my js:
$(document).ready(function() {
var table = $('#gudang-table').DataTable({
"ajax": {
url: '{!! route('getgudang') !!}',
type: "GET",
dataType: 'json',
dataSrc: "",
},
columns: [
{ data: 'id' },
{ data: 'kode'},
{ data: 'name'},
{ data: 'wilayah'},
{ data: 'alamat'},
{ data: 'kota' }
]
});
});
and this is my json response :
[{"id":1,"name":"PT.PELINDO II","kode":"101U","wilayah":"Tanjung Priok","alamat":"LAP 101U-101","kota":"Jakarta"},{"id":2,"name":"PT.PELINDO II","kode":"106X","wilayah":"Tanjung Priok","alamat":"LAPANGAN 106X","kota":"Jakarta"},{"id":3,"name":"PT.PELINDO II","kode":"221X","wilayah":"Tanjung Priok","alamat":"LAPANGAN 106X","kota":"Jakarta"},{"id":4,"name":"PT.PELINDO II","kode":"223X","wilayah":"Tanjung Priok","alamat":"LAP 223X","kota":"Jakarta"}]
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
This section of the FAQ should help, it discusses various techniques to improve performance,
Cheers,
Colin
There isn't anything obvious. In what way does it not work?
Do you get alert messages or errors in the browser's console?
Kevin