Problem with SSP
Problem with SSP
Hello everyone.
cant figure out how to make it work right way.
**LInk **https://www.primoportal.de/marktanalysen/
**JS code **
! jQuery('#example').DataTable( {
! "pagingType": "numbers",
! "processing": true,
! "serverSide": true,
! "ajax": { "url" : "/wp-content/themes/dms/server_processing_marktanalysen.php",
! "data": function (d) {
! return {
! search: d.search.value,
! page: d.start,
! size: d.length
! }
! },
! dataSrc: function(data) {
! data.recordsTotal = data.totalElements;
! data.data = data.content;
! return data.data
! },
!
! },
! columns: [
! { 'data' : '1' },
! { 'data' : '2' }
! ],
! "autoWidth": false,
! "language": {"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json" }
! });
! });
Errors in concole:
Uncaught TypeError: Cannot read property 'length' of undefined jquery.dataTables.js:4126
ajax return this
http://prntscr.com/jv23k6
How should i change JS code to show fields pagination
Thanks
Replies
It looks like your ajax response has the correct fields according to the SSP doc. However it looks like your server script is not setup for SSP or maybe returning incorrect values due to your ajax data option. Its returning all rows (29733). Also the recordsFiltered and recordsTotal don't have the correct values. It looks like you are dropping the
draw
value in the request.What are you using for your server script? Looks like it is somewhat set up to return the proper values but is not working.
I would start by removing your ajax data option to send the request data as Datataables normally would and remove your dataSrc function as your server script seems to be responding with the correct parameters.
If you still have issues then we probably need to look at your server script.
Kevin
@kthorngren Thanks for reply
I changed the code to this one:
Now it shows first 10 rows in table, http://prntscr.com/jv89dm
but response is still with incorrect values
{"draw":1,"recordsTotal":0,"recordsFiltered":0,"data":[["Baugrundst\u00fccke","Frohnau"],["Baugrundst\u00fccke","Reinickendorf"],["Baugrundst\u00fccke","Spandau"],["Baugrundst\u00fccke","Mitte"],["Baugrundst\u00fccke","Mitte"],["Baugrundst\u00fccke","Unterfrank........
Im using this serverscript https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/ssp.class.php
Hi @artem4ik19 ,
The
recordsTotal
andrecordsFiltered
being 0 is causing this. If you imagine the table info string, "Showing 1 to 10 of 12 entries (filtered from 57 total entries)",recordsTotal
should be the total number of records (57),recordsFiltered
should be the number of records that match the criteria (12).It would be worthwhile looking at Ajax tab on this page, that should make it more clear.
Cheers,
Colin
@colin I understand what recordsTotal and recordsFiltered means, but problem is why server returns 0 values for them((
oh, i found problem
i was using ID column as $primarykey instead of ref_pk http://prntscr.com/jv9cr2