I have some code i've been working on to have a box disappear once you click a button without refreshing the whole page, I can't get over my current hurdle. My AJAX doesn't seem to be posting any data, as you can see from the code below, I have a confirmation pop up which works and does pop up and when you click ok it SHOULD POST the ID to another page where the SQL runs, but it doesn't and i've tried testing it with echoing the POST to see if it retrieves it and no luck.
Any ideas why it won't post the data?
P.s I've checked to make sure the function is correct but here it is so you can see what the user clicks, and the id is 100% there
<button onclick='good(<?= $appRow['customer_appointments_id']; ?>)' class='w3-button w3-block w3-green w3-section'><i class='fa fa-check'></i></button>
AJAX
function good(id){
if (confirm("Are you sure you want to complete this appointment?")) {
$.ajax({
type: "POST",
url: "scripts/lead/completeLeadTask.php",
data: ({
id: id
}),
cache: false,
success: function(html) {
$(".delete_mem" + id).fadeOut('slow');
}
});
Scripts/lead/completeLeadTask.php
echo $_POST['id'];
$stmt = $dbh->prepare("UPDATE `customer_appointments` SET `customer_appointments_status` = 'c' WHERE `customer_appointments`.`customer_appointments_id` = ?")->execute([$_POST['id']]);
$stmt = null;
alert(id);