Why SSP with POST method is slowing down DataTable

Why SSP with POST method is slowing down DataTable

EnzoChengEnzoCheng Posts: 15Questions: 3Answers: 0

Description of problem: I am trying to send data to the PHP script for WHERE IN database query. I followed the example https://datatables.net/examples/server_side/post.html , but it slows down the DataTable and the table processing is never finished.

DataTable:

      let table =  $('#membership-profile-table').DataTable({
      "deferRender": true,
      "aLengthMenu": [
        [5, 10, 15, -1],
        [5, 10, 15, "All"]
      ],
      "iDisplayLength": 20,
      "language": {
        search: "Search"
      },
      "processing": true,
      "serverSide": true,
      "ajax": {
        url:createMemberListPath,
        data:{test:123},
        type:"POST",
      }
   });

PHP:

<?php

use App\DataTable\SSP;


include realpath("../../vendor/autoload.php");

use const App\Mysql\DB_HOST;
use const App\Mysql\DB_NAME;
use const App\Mysql\DB_PASSWORD;
use const App\Mysql\DB_USER;

require("C:/xampp/.config.php");


$dbDetails = array (
    "host" => DB_HOST,
    "user" => DB_USER,
    "pass" => DB_PASSWORD,
    "db" => DB_NAME

);

$table;

if(isset($_POST["test"])){
    $table = "mas_membership";
}

$primaryKey = "M_CODE";

$columns = array(

    array("db"=>"M_CODE",
          "dt"=>"DT_RowId",
        'formatter'=>function($d,$row){
            return "row_".$d;   
        }),
    array("db"=>"M_CODE","dt"=>0),
    array("db"=>"M_DESC","dt"=>1),
    array("db"=>"M_DESC2","dt"=>2),
    array("db"=>"M_MOBILE","dt"=>3),
    array("db"=>"M_EMAIL","dt"=>4),
    array("db"=>"M_BIRTHDAY", "dt"=>5,
         
        'formatter' => function($d,$row){
            return date('d-M-Y',strtotime($d));
        }
    ),

);

echo json_encode(
    SSP::simple($_GET,$dbDetails,$table,$primaryKey,$columns)
);

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394
    Answer ✓

    You are sending POST but expecting GET.

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

This discussion has been closed.