datatable waits more than 15 seconds to load
datatable waits more than 15 seconds to load
im using datatable like this
$('#provincedataTable').DataTable({
paging:true,
info:true,
ordering:true,
autoWidth:true,
Processing: true,
ServerSide: true,
ajax: 'province/provinces-json',
columns: [
{data: 'select'},
{data: 'code'},
{data: 'name'},
{data: 'options'}
],
"fnDrawCallback": function() {
Checkboxs();
}
});
and the datatable waits more than 15 seconds till it load all the data first then show the first 10 records !!
i want it to load the first page only and when i click the page number it should load from the server
i think this is the right behaviour
how i can do that?
thanks in advance.
This question has an accepted answers - jump to answer
Answers
At serverside in php and mysqli you can limit the recordlength .
no i do not to load a limited number
i want all 4000 record to load buty paginated
so only the page which contains 10 records only loads
and when i click on any page it loads those 10 records on it
the behaviour now is when the page loaded it waits so long till it loads all 4000 records then the table appears
There is no
ServerSide
option - it isserverSide
(note the case - Javascript is case sensitive).edit Also, does your
ajax: 'province/provinces-json',
script implement server-side processing?Allan
now it is like this and still the same behaviour !!
and im using for server isde script package called
"yajra/laravel-datatables-oracle": "6.0.x-dev"
I haven't used that package, so I can't really comment on it. Is it correctly responding with the information required in the link I gave?
Allan
the data is returned and it is ok but the problem is
it loads all the data first before show the table showing Loading... indicator
and that take more than 20 seconds for those 4000 records
now i use this code
this famous error appear
datatables requested unknown parameter 0 for row 0
but the data on the console i see only 10 records came ..
so now the return is correct but it does not appear on the page due to this above error
the problem in using columns: [] when i remove it this new error came
what i can do for this new error?
thanks in advance.
We'd really need a link to the page in question. I can really only guess at the moment.
If all 4000 rows are being loaded that the server-side script is not correctly performing server-side processing.
Allan
this code works but show error
$('#provincedataTable').DataTable({
processing: true,
serverSide: true,
ajax: 'province/provinces-json',
"fnDrawCallback": function() {
Checkboxs();
}
});
the error datatables requested unknown parameter 0 for row 0
i see the data only in the console of the browser shows 10 records
means every thing goes good but this error stops it from appear on the page
What is the JSON that
'province/provinces-json'
returns?normal json generated by this package
http://datatables.yajrabox.com/
and this is sample lines
{
"draw": 0,
"recordsTotal": 4099,
"recordsFiltered": 4099,
"data": [
{
"id": 2971,
"country_id": 195,
"name": "Álava",
"code": "AL",
"status": 1
},
{
"id": 2976,
"country_id": 195,
"name": "Ávila",
"code": "AV",
"status": 1
}
That is not valid for server-side processing. It must be at least 1. Therefore there is something going wrong. Is it expecting POST data perhaps?
Allan
im sorrry one final thing
im following this tutorial and the draw is 0 and it is working
http://datatables.yajrabox.com/fluent/basic
It looks correct to me:
Allan
no it is 0
look on this json file used
http://datatables.yajrabox.com/fluent/basic-data
I promise you, if you open your browser's network tools and then click to change a page in the DataTable, then take a look at the JSON response from the server. You'll see that it is changing the draw parameter in the returned data.
Allan