I researched and still could not solve this problem. is an onclick event that sends a request to the update.php file, which makes an update to the notifications table. Here is the code below:
Triggers the onclick event:
<input type="hidden" name="id" id="id" value="'.$id.'">
<a onclick="sendData()" href="#">
Ajax from this page:
<script>
function sendData()
{
var id_n = $('#id').val();
$.ajax({
type:"POST",
url:"update.php",
data: { id: id_n },
contentType: false,
cache: false,
processData: false,
success:function(dta)
{
alert(dta);
}
});
}
</script>
Excerpt from update.php file, code:
$id = ($_POST['id']);
$sql = "UPDATE notif SET status = 1 WHERE id = :id";
$res = $pdo->prepare($sql);
$res->bindParam(':id',$id);
$res->execute();
$pdo->close();
What could be wrong? Thankful for attention.