I'd like to refresh the div when a message is deleted from my cat How to make it work?
I've put a piece of code.
Thank you in advance.
<script type="text/javascript">
function deleteBox(id){
if (confirm("Confirnez-vous la suppression du message?"))
{
var dataString = 'id='+ id;
$.ajax({
type: "POST",
url: "del.php",
data: dataString,
cache: false,
success: function(result){
if(result){
// if data delete successfully
if(result=='success'){
//Check random no, for animated type of effect
var randNum=Math.floor((Math.random()*100)+1);
if(randNum % 2==0){
// Delete with slide up effect
$("#chat-item_"+id).slideUp(1000);
// HERE
}else{
// Just hide data
$("#chat-item_"+id).hide(500);
}
}else{
var errorMessage=result.substring(position+2);
alert(errorMessage);
}
}
}
});
}
}
</script>
Thank you for your help
In your del.php file you can run a query that gets all messages after you have deleted the one you want. Then echo the html to fill the div.
Then on your Javascript side you can have it set the div's html to the data that is echoed back('results' variable).