I'm building an app using as back-end laravel framework that sends some data to the front-end and renders them using DataTables. In the back end I'm using yara's laravel plugin and the code looks like :
public function getData()
{
return datatables()->query(DB::table('data'))->toJson();
}
In the front-end now, I have this simple code to render the table:
<table class="table table-bordered" id="table">
<thead>
<tr>
<th>id</th>
<th>GSE</th>
<th>Species</th>
<th>Entity</th>
<th>Technology</th>
<th>Type</th>
<th>Samples</th>
<th>Duplicates</th>
<th>Diseases</th>
<th>ParentNode</th>
<th>ChildNode</th>
<th>datapath</th>
<th>DOlink</th>
<th>dsetLink</th>
<th>Annot</th>
<th>Title</th>
</tr>
</thead>
</table>
</div>
<script>
$(function() {
$('#table').DataTable({
serverSide: true,
processing: true,
ajax: 'http://localhost:8181/getData',
columns: [
{ data: 'id', name: 'id' },
{ data: 'GSE', name: 'GSE' },
{ data: 'Species', name: 'Species' },
{ data: 'Entity', name: 'Entity' },
{ data: 'Technology', name: 'Technology' },
{ data: 'Type', name: 'Type' },
{ data: 'Samples', name: 'Samples' },
{ data: 'Duplicates', name: 'Duplicates' },
{ data: 'Diseases', name: 'Diseases' },
{ data: 'ParentNode', name: 'ParentNode' },
{ data: 'ChildNode', name: 'ChildNode' },
{ data: 'DataPath', name: 'DataPath' },
{ data: 'DOLink', name: 'DOLink' },
{ data: 'Dsetlink', name: 'Dsetlink' },
{ data: 'Annot', name: 'Annot' },
{ data: 'Title', name: 'Title' }
]
});
});
</script>
The table has in total 5,687 entries and the problem is that it doesn't always get rendered as expected. For example, when I load for first time the page I'm getting the DataTables warning: table id=table - Ajax error which seems to be a not found one.
Then If I count 3 seconds from that first fail and press again refresh, the table gets loaded as expected.
Is there any explanation for that? Is it a timing problem?
Any idea is welcomed!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire