Why does pageLength not have a value?
Why does pageLength not have a value?

Link to test case: https://demos.turf.gg/
Debugger code (debug.datatables.net):
Error messages shown: No error message, but it is not working
Description of problem: So I'm trying to get the number of results per row that should be shown by the user.
Here is my datatable variable:
var table = $('#example').DataTable( {
"order": [[ 0, "desc" ]],
"ajax": "./inc/database.php",
"type": "GET",
"lengthMenu": [ 10, 25, 50, 100 ],
"pageLength": 10,
"columns": [
{ "data": "id" },
{ "data": "download" },
{ "data": "recorded" },
{ "data": "expires" },
{ "data": "server" },
{ "data": "map" },
{ "data": "t" },
{ "data": "ct" },
{ "data": "roundtime" },
{ "data": "winner" },
{ "data": "file", "bVisible": false }
],
"oLanguage": {
"sLengthMenu": "Show _MENU_ results per page",
"sSearch": "Search from all columns: "
}
} );
And then I'm trying to print out the amount of rows the client selected per page with PHP:
echo isset($_GET["pageLength"]) ? $_GET["pageLength"] : "No value";
But it prints "No value" even tho I set the "pageLength" value. Why?
This discussion has been closed.
Answers
pageLength is not accessible that way.
You want page.len().
https://datatables.net/reference/api/page.len()
How can I access that in PHP then?
I'm not clear why you want to access the page length on the server? Are you intending to use
serverSide
? That needs it, but for plainajax
, you just send back all data for the table,Colin