Server-side processing - custom filter - problem after adding type:POST

Server-side processing - custom filter - problem after adding type:POST

culterculter Posts: 102Questions: 24Answers: 0

Hi, I would like to create some custom filters. I found some tutorials, but I have problem with the ajax type. In all of these tutorials, the ajax needs the setting "type": "POST". When I add this row to script (I suppose that when there is no type, the type is "GET"), the table will not load and the error in apache error log is:

[Mon Oct 22 10:36:48.588801 2018] [:error] [pid 19553] [client 10.10.10.1:60141] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 7504929 bytes) in /var/www/html/scripts/server_processing.php on line 65, referer: http://10.10.10.11/

My script:

$(document).ready(function() {
   var table = $('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": {
                "url": "scripts/server_processing.php",
                type: 'POST'
                },
        columns: [
                {
                        "visible":      false,
                        "className":    'details-control',
                        "orderable":    false,
                        "data":         null,
                        "defaultContent":       ''
                },

                {data: 0},
                {data: 1},
                {data: 2},
                {data: 3},
                {data: 4},
                {data: 5},
                {data: 6},
        ],
        "lengthMenu": [[10,25,50,100],[10,20,50,100]],
        "order": [[1, 'asc']],
        "columnDefs": [{
                "targets": 7,
                "render": function (data, type, row) {
                        return data.substr( 0,20 );
                        }
        }],

    });

Thanks for any advice.

This question has an accepted answers - jump to answer

Answers

  • culterculter Posts: 102Questions: 24Answers: 0

    Ok, I tried to change memory_limit in php.ini from 128M to 1024M and after this change I did'nt get Internal sever error, but instead several tousands of rows are loaded. So, do I need to change type to POST to make custom filters or not? Thanks.

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin
    Answer ✓

    It depends on how you have configured server_processing.php. Is it expecting POSt or GET parameters?

    Allan

  • culterculter Posts: 102Questions: 24Answers: 0

    So I switched this line from this:

    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )

    to this:

    SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns )

    and also the type in the ajax call and it's working. I'm confused. Is there a difference in the functionality when I use Get or Post or not or it does'nt matter? Thanks

This discussion has been closed.