I am trying to delete the data against the remove (Ajax) option.When i click the remove button it deletes the data from the database and the page should automatically disappear the data.But it does not happen,it deletes the data but not disappeared from the screen.When i refreshed the page then in the page the data is disappeared......Please help me
The html code...
<table><tr><td><a href="javascript:remove()">Remove</a></td>
<td id="resId"></td></tr></table>
The ajax function is....
function remove(){
var http = GetXmlHttpObject();
http.onreadystatechange = function()
{
if(http.readyState==4)
{
document.getElementById("resId").innerHTML = http.responseText;
//alert(http.responseText);
}
}
var name1 = document.getElementById("bn").innerHTML;
//alert(name);
var url = "index.php?menu=remove_cart&ajax=ajax&q="+name1;
http.open('POST',url,true);
http.send(null);
}
And the PHP function is....
function remove_cart($name1){
global $template;
$sql = "DELETE FROM tbl_buy WHERE b_name = '$name1'";
$this->db->executeQuery($sql);
$template->main_content = $template->fetch(TEMPLATE_DIR . 'my_cart.htm');
}