John Davidson

javascript - 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() {
"destroy": true,
"serverSide": true,
"processing": true,
"paging": false,
"searching": false,

columns: [{
data: "d"
data: "c"
data: "p"
ajax: {
type: "POST",
data: {
"species": s
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">


My Answer:
JavaScript and PHP are both popular programming languages used for web development, but they have different purposes and are often used together in web applications.

JavaScript is a client-side scripting language that is used to create interactive and dynamic elements on a website. It is primarily used for front-end development, such as creating animations, form validation, and interactive features.

PHP, on the other hand, is a server-side scripting language that is used to create dynamic web pages and interact with databases. It is often used for back-end development, such as processing form data, generating dynamic content, and handling user authentication.

While JavaScript and PHP can both be used independently to create web applications, they are often used together to create a full-stack web application. For example, PHP can be used to handle server-side processing and database interactions, while JavaScript can be used to create interactive elements on the front-end.

Overall, JavaScript and PHP are both important languages in web development and are often used together to create dynamic and interactive web applications.

Rate this post

3 of 5 based on 3181 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us