Delete record without refresh page using php

Sealongmaly picture Sealongmaly · Sep 27, 2012 · Viewed 12k times · Source

I have HTML and PHP code as below:

HTML

<a href="deleteData.php?id=<?php echo $value['id']?>"><button name="delte" class="btn">Delete</button></a>

deleteData.php

<?php
include ('include/connectdb.php');
$getid = $_GET['id'];
$sql = ("UPDATE tblworkfaire SET status=0 where id = ".$getid);
$res = mysql_query($sql) or die (mysql_error());

?>

This works great except that after the record is deleted the record is still displayed on the page until it is refreshed.How do I fix this.Anyone have any idea help me please.Thanks,

Answer

swapnesh picture swapnesh · Sep 27, 2012

Try Something like this ---

jQuery.ajax({
        type: "GET",
        url: deleteData.php,
        data:{'id':id},
        success:function(results)
        {   
                 .....
        }
        });