my page should update with mysql table content always. i made a ajax function. but when i click refresh button, duplicating same result. i want to show one table raw only once. here is my ajax function.
//page upload function
$("#display").click(function() {
$.ajax({ //create an ajax request to load_page.php
type: "POST",
url: "display_status.php",
dataType: "text", //expect html to bereturned
success: function(response){
$("#responds").append(response);
//alert(response);
}
});
});
});
</script>
<ul id="responds">
</ul>
<input type="button" id="display" value="Refresh Page" />
then this is my php page (display_status.php)
$results = $dbc->query("SELECT * FROM status where student_id='$stu_id'");
//get all records from add_delete_record table
while($row = $results->fetch_assoc())
{
echo '<li id="item_'.$row["status_id"].'">';
echo '<div class="del_wrapper"><a href="#" class="del_button" id="del-'.$row["status_id"].'">';
echo '<img src="images/icon_del.gif" border="0" />';
echo '</a></div>';
echo $row["status"].'</li>';
instead of append ,use this:
var prev=$("#responds").text();
var res=prev+response;
$("#responds").html(res);