Can't send data to server via ajax
Can't send data to server via ajax
azonekz@gmail.com
Posts: 32Questions: 9Answers: 1
mytable = $("#Programme1").DataTable
({
dom:"Blfrtip",
ajax: "php/demandes.php",
type: 'POST',
data: {
prog:1
},
On a server side:
$p=$_POST['prog'];
Error is:
Notice: Undefined index: prog in C:\xampp\htdocs\MyPHPproject\php\demandes.php on line 22
Can you help me please?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are you trying to combine the url, type and data in your ajax config, similar to this example?
https://datatables.net/reference/option/ajax.data#Examples
If so then you need to change your syntax to something like this:
Kevin
Thanks for reponse,
I've tryed it, but have the same error
What is line 22 of demandes.php?
Maybe you can provide more of your demandes.php code so we can see what is leading up to line 22.
Kevin
now the error is:
Notice: Undefined index: prog in C:\xampp\htdocs\MyPHPproject\php\demandes.php on line 14
Does error occur when you are submitting edited data, or when you are loading the DataTable? If the former (which I am guessing is the case) you need to use
ajax.data
in the Editor options to set the data being sent to the server as well as doing it for the DataTable.Allan
The error occur when I'm loading the DataTable
Yes, it'working great with ajax.data, thank you!!!