Hello, I am currently working on dynamically removing database entries using JS and AJAX without having to refresh the entire page. Here is a snippet from my data.php file:
<?php
require_once('db.php');
if (isset($_GET['list'])) {
$query = "SELECT * FROM message";
mysql_query("SET NAMES 'UTF8'");
$qq=mysql_query($query);
$i = 1;
echo '<div id="rezult">';
while($ff = mysql_fetch_array($qq)){
echo '<div id="id'.$ff['id'].'">'.$i++.'. Name: '.$ff['name'].' Message:'.$ff['message'].'</div>';
}
echo '</div>';
}
?>
This code helps me fetch data from a MySQL table in my project:
index.php
function list() {
$.get('data.php?list=1', function(o) {
$('#list').html(o);
});
}
Any suggestions on how to delete a specific entry dynamically without refreshing the page? I attempted to include the following code as a link within the entry, but it seems to cut off when reaching javascript:$.post(
.
<a href="javascript:$.post('delete_post.php', { id: '$ff[id]' } );" class='delete_post' title='delete post'>delete post</a>
I appreciate any advice or guidance on this matter.