I am using this javascript code to object a data of a td when pressing a button in an onclick event
function rfk(element) {
var element = element.parentElement.parentElement;
var id = parseInt(element.children[0].innerText);
$.ajax({
url: './queryuser.php',
type: "POST",
dataType:'text',
data: {'id': id},
});
}
when using an alert instead of var = id shows the value of the td
but this is failing the sentence of ajax when sending to php I do not know how to solve it
PHP code queryuser.php :
<?php
require("conextion.php");
require("sql.php");
$connect=start();
$display= show($connect,$_POST['id']);
disconnect=($connect);
header("Location:index.php");
?>
Query sql:
function show($con, $id){
$query=" SELECT user_name FROM user
WHERE $id='?'";
$call = $con->prepare($query);
$call ->execute();
return $call;
}