I am trying to send an ID to a PHP page to update a database. First time using AJAX.
I keep getting an error. The PHP file is in the same directory
function approve(id) {
$.smallBox({
title : "Are you sure you would like to approve this indicator?",
content : "<p class='text-align-right'><a href='javascript:approve_indicator(" + id + ");' class='btn btn-primary btn-sm'>Yes</a> <a href='javascript:void(0);' class='btn btn-danger btn-sm'>No</a></p>",
color : "#296191",
//timeout: 8000,
icon : "fa fa-bell swing animated"
});
}
function approve_indicator(id){
$.ajax({
url: '/approve_indicator.php',
type: 'post',
data: 'id='+id,
success: function()
{
alert('success, server says '+output);
location.reload();
}, error: function()
{
alert('something went wrong, rating failed');
}
});
}
this is the PHP. Not sure if it matters
$id = $_POST['id'];
$update_indicator = $con->preapre("UPDATE indicators SET approved = ? WHERE indicator_id = ?");
$update_indicator->execute(array(1,$id));