Dopo aver compilato questo script perfettamente funzionante per gestire l'eliminazione dei commenti
codice:
<?
include 'function.php';
$data = new MysqlClass();
$data->connetti();
?>
<!DOCTYPE html>
<html lang="it" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<?
$head_sql = $data->query("SELECT * FROM head WHERE type !=1");
while($head_obj = $data->estrai($head_sql)){
$value_head = $head_obj->value;
echo $value_head;
}
?>
<link rel="stylesheet" href="css/over.css">
</head>
<body>
<? $comment_sql = $data->query("SELECT * FROM comment");
while($comment_obj = $data->estrai($comment_sql)){
$id_comment = $comment_obj->id;
$value_comment = $comment_obj->value;
echo '
'.$author_comment.'
'.$value_comment.'</p>';
echo 'Cancella questo commento';
}
?>
</div>
</div>
</body>
</html>
<script>
$(function() {
$('.cancel').click(function(){
var id = $(this).attr('href');
if (confirm('Sei sicuro di voler cancellare il commento?')){
$.post("delete.php", { id: id, tab: 'comment', rand: Math.random() }, function(del_res){
location.reload();
});
}
return false
});
});
</script>
Testato e funzionante ho deciso di adattarlo per eliminare i post cosi...
codice:
<?
include 'function.php';
$data = new MysqlClass();
$data->connetti();
?>
<!DOCTYPE html>
<html lang="it" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<?
$head_sql = $data->query("SELECT * FROM head WHERE type !=1");
while($head_obj = $data->estrai($head_sql)){
$value_head = $head_obj->value;
echo $value_head;
}
?>
<link rel="stylesheet" href="css/over.css">
</head>
<body>
<? $comment_sql = $data->query("SELECT * FROM post_ita");
while($comment_obj = $data->estrai($comment_sql)){
$id_comment = $comment_obj->id;
$value_comment = $comment_obj->value;
echo '
'.$author_comment.'
'.$value_comment.'</p>';
echo 'Cancella questo commento';
}
?>
</div>
</div>
</body>
</html>
<script>
$(function() {
$('.cancel').click(function(){
var id = $(this).attr('href');
if (confirm('Sei sicuro di voler cancellare il commento?')){
$.post("delete.php", { id: id, tab: 'post_ita', rand: Math.random() }, function(del_res){
location.reload();
});
}
return false
});
});
Ebbene nel secondo esempio la pagina non funzione e cliccando sul link di classe .cancel mi rimanda alla pagina localhost/1 che ovviamente non esiste...
Non è un problema di php perché gli elementi li lista correttamente...
(PS nella prima versione era presente anche un altro pulsante attivato tramite jquery che smetteva di funzionare se si sostituiva comment con post_ita)
Qualche idea del perché di questo comportamento???