successo del pulsante simile ajax non corretto
Aug 17 2020
Stavo creando un pulsante mi piace con php e ajax/jquery e non verrà ricaricato quando fai clic su di esso ricaricherà solo il div ma ricaricherà il div ma il numero di mi piace non aggiunge qui il mio codice.
<div id="Post-ImVi-Action">
<script>
$(document).ready(function () {
$('#Post-ImVi-Action-Like').click(function (e) {
e.preventDefault();
var name = $('#Like_Poster_name').val();
var email = $('#Like_Post_1').val();
$.ajax
({
type: "POST",
url: "php-SocialMedia-Posting-Like.php",
data: { "Poster_name": name, "Post_1": email },
success: function (data) {
$("#Post-ImVi-Action-Like").html(data);
}
});
});
});
</script>
<input type="Hidden" name="Poster_Name" id="Like_Poster_name" value="<?php echo $Post_Row["Poster_Name"];?>">
<input type="Hidden" name="Post_1" id="Like_Post_1" value="<?php echo $Post_Row["Post_1"];?>">
<input type="Hidden" name="ID" id="Like" value="<?php echo $Post_Row["ID"];?>">
<button id="Post-ImVi-Action-View">158K</button>
<button id="Post-ImVi-Action-Like" type="button" name="Like_Button" >
<?php
$Post = $Post_Row["Post_1"];
$Sql_like_count = "SELECT * FROM `likes` WHERE post = '$Post'";
$Result_like_Count = mysqli_query($conn, $Sql_like_count);
while ($ROW_LIKE = mysqli_fetch_array($Result_like_Count)) {
echo $ROW_LIKE['Likes'];
}
?>
</button>
<button id="Post-ImVi-Action-Share">815</button>
<div id="Post-ImVi-Action-Face"></div>
</div>
Ecco php-SocialMedia-Posting-Like.php
<?php
include"php-MAIN-Info.php";
include"php-MAIN-SignUp+Database.php";
$Post = $_POST['Post_1'];
$Poster_Name = $_POST['Poster_Name'];
$Sql = "SELECT* FROM Likes WHERE Post = '$Post' AND Poster_Name = '$Poster_Name'";
$Like_Result = mysqli_query($conn, $Sql);
while ($Like_Row = mysqli_fetch_array($Like_Result)) {
$Like_Add = $Like_Row['Likes'] + '1';
$Sql_Like_Add = "UPDATE Likes SET Likes = '$Like_Add' WHERE Post = '$Post' AND Poster_Name = '$Poster_Name';";
$Like_Result_Add = mysqli_query($conn, $Sql_Like_Add);
if ($Like_Result_Add) {
echo $Like_Add;
}
}
aggiornamento: ho trovato un errore
php-Home-MSOHome.php:352 Uncaught ReferenceError: i dati non sono definiti
per favore prova ad aiutare perché sono nuovo su questo web. Grazie perché nessuno risponde alla mia domanda stai ancora cercando le risposte
Risposte
Noname Aug 20 2020 at 11:05
L'ho fatto è un errore php udfinde Poster_name
itsPoster_Name