here is what I would do in order to debug and get the php errors into javascript console.log after an ajax call:
$('#ChangePermission').click(function () {
$.ajax({
url: 'change_permission.php',
type: 'POST',
data: {
'user': document.GetElementById("user").value,
'perm': document.GetElementById("perm").value
},
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
});
on the php side I would start by asking for all error returned to string concat and echo as a json encoded response that will includes php error messages as well if any.
<?php
error_reporting(E_ALL);
require_once(functions . php);
$result = "true";
$DBH = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$STH = $DBH->prepare("INSERT INTO people ( username, permissions ) values (?, ?)");
if (isset($_POST["user"]) && isset($_POST["perm"])) {
$STH->bindParam(1, $_POST["user"], PDO::PARAM_STR);
$STH->bindParam(2, $_POST["perm"], PDO::PARAM_STR);
}
try {
$STH->execute();
} catch (PDOException $e) {
$result .= $e->getMessage;
}
echo json_encode($result);
?>