1
I did some research, and I still can’t solve this problem. is an onclick event that sends a request to the update.php file, which updates the notification table. Follows 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? Grateful for the attention.
What’s the matter with you? What is
'#id'
? oneinput
?– Sergio
It showed no error. I reviewed the code and removed "contenttype:False" "processData: False" and ran only the GET method. What could be wrong to work the POST? The #id comes from the value of an input
– AdrianoLeal