I've got a little issue with a function I'm developing. I've got an anchor <a>
in a list of table's row generated dynamically with a database query. All I want to do is to remove a record in my database calling a php script without reloading page.
Here my function:
$(document).on("click",".scollega", function () {
var id_professionista = $(this).attr('id');
var id_geocentro = $("#selezione_centri option:selected").val();
var link_to_trigger = "scollega_prof.php?id_professionista="+id_professionista+"&id_geocentro="+id_geocentro;
alert(link_to_trigger);
//the code above is working fine, I got an alert with corret url to trigger
e.preventDefault();
$.ajax({
async: true,
cache: false,
url: link_to_trigger,
type: 'GET',
contentType: false,
processData: false,
success:function(){
alert("Record rimosso");
var string = ('scripts/server_processing.php?id_geocentro='+id_geocentro);
table.ajax.url(string).load();
table.reload();
},
error:function (){
alert("Si è verificato un errore");
}
});
});
PHP Code:
<?php
session_start();
session_cache_limiter('nocache');
if(!isset($_SESSION['mail'])){
header("location:login.php");
}
include("include/connect.php");
$conn=mysql_connect($HOST, $USER, $PASSWORD);
$db_ok=mysql_select_db($DB, $conn);
$query="DELETE FROM centri_operativi WHERE id_professionista='".$_GET['id_professionista']."' AND id_geocentro='".$_GET['id_geocentro']."'";
$ris=mysql_query($query, $conn);
mysql_close($conn);
?>
It seems right, but every time I click my button, nothing happens. I'm not able to see
neither the error message.
Hope someone will help me. Thank you guys.
Giacomo.