First of all, I have already read through many other posts and tried different things, but no solution approach has worked so far.
My problem: ajax does not send the POST data.
fillTable.js
function fillTableWithData(htmlID, tableSQL, colsSQL, orderSQL){
var jsondata = new FormData();
jsondata.append("action", htmlID);
jsondata.append("table", tableSQL);
jsondata.append("cols", colsSQL);
jsondata.append("order", orderSQL);
$.ajax({
url:"table.php",
method: "POST",
dataType: 'json',
contentType:false,
processData:false,
data: jsondata,
success:function(result){
// $(htmlID).html(result);
alert("test");
}
});
}
table.php
<?php
require('db.php');
echo (count($_POST)); // result is 0
if(isset($_POST['action'])){ // not set
if($_POST['action'] == "getDataAsRows"){
getDataAsRows($_POST['table'], $_POST['cols'], $_POST['order']);
}
}
function getDataAsRows($table, $cols, $order) {
...
}
?>
Both files are inside the same folder:
/scripts/fillTable.js
/scripts/table.php
The url should not be a problem, since the php code prints out the length of $_POST.