I'm trying to update a row using Ajax, it failed.
Here my code
<button onclick="updateAjax(<?php echo $row['id_doc']; ?>,this)" class="btn btn-danger">Delete</button>
function updateAjax(id_doc,obj){
$.ajax({
  type: 'get',
  url: 'toIndex.php',
  data: {nama_file:id_doc},
  success:function(data){
    data = JSON.parse(data);
    if(data){
      alert("Data berhasil diupdate");
    }else{
        alert("Data gagal diupdate");
    }
  }
}); }
On the toIndex.php page
$nama_file = $_GET['nama_file'];
$update = "UPDATE documents SET status_index = 1 WHERE nama_file='".$nama_file."'";
if($conn->query($update) == TRUE){
   echo json_encode(true);
}else{
   echo json_encode(false);
}
the alert("Data berhasil diupdate") is work, but the mysqli query is failed to update the data.
Any solution?
 
     
    