Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
PHP doesn't receive ajax post data

I have been struggling with it for a week...I want to use Ajax in datatables to pass some parameters to my PHP file for server side searching. But it seems my PHP file got nothing. But the datatable works just fine and the table can return from sever side processing and display on the html page correctly. However, var_dump( $_POST['species']) returns null.

  $(document).ready(function() {
    console.log(species);
    $("#table").DataTable({
      "destroy": true,
      "serverSide": true,
      "processing": true,
      "paging": false,
      "searching": false,

      columns: [{
          data: "dRid"
        },
        {
          data: "chromosome"
        },
        {
          data: "position"
        }
      ],
      ajax: {
        type: "POST",
        data: {
          "species": species
        },
        url: "./php/search_test.php"
      }

    });
  });
<div class="container text-center" id="tablecontainer" name="tablecontainer">
  <table id="table" class="display nowrap row-border strip p-2" cellspacing="0" width="100%">

    <thead class="thead-dark">
      <tr>
        <th>
          <center>directRMDB ID</center>
        </th>
        <th>
          <center>Chromosome</center>
        </th>
        <th>
          <center>Position</center>
        </th>

      </tr>
    </thead>
  </table>
</div>

'''php

ini_set ('memory_limit',  '2048M');
$sql_details = array(
'host' => 'localhost',
'user' => 'root',
'pass' => '',
'db'   => 'xxxxx'
);

// DB table to use
$table = 'homo_sapiens';

//if I try this here: $species=$_POST["species"]; echo $species;It //returns: Warning: Undefined array key "species".

// Table's primary key
$primaryKey = 'dRid';

// column
$columns = array(
array( 'db' => 'dRid', 'dt' => 'dRid' ),
array( 'db' => 'chr', 'dt' => 'chromosome' ),
array( 'db' => 'pos',  'dt' => 'position' ),


);

// Include SQL query processing class
require( 'ssp.class.php' );

echo json_encode(
SSP::complex( $_POST, $sql_details, $table, $primaryKey,$columns)
);

Could someone help me with it? Thanks.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this. Replace $_POST to $array

$array = json_decode(file_get_contents('php://input'), true); print_r($array);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!