Reputation: 113
I want to remove a some record from my database while clicking on delete button. Currently I am using this code:
function removeItem(id) {
$.ajax({
url:"removeItem_checkOut.php",
type:"GET",
data:"id="+id,
success:function(content) {
window.location.reload();
}
});
}
In removeItem_checkOUt.php I am simply running the delete query.
It works fine for me, but the problem with this code is that it reload the entire page. I just want to do it without reloading the page.
Simple saying is this that the functionality of the above code is good but i am unable to do it without the reloading the page. Until the page reload, it is does not disappear for the page.
Can anyone help me please....
Upvotes: 0
Views: 293
Reputation: 800
function removeItem(id) {
$.ajax({
url:"removeItem_checkOut.php",
type:"GET",
data:"id="+id,
success:function(html) {
$('#div_contains_data').html(html); //put your div id of the content (if it is a table use that table inside a div)
}
});
}
and in your removeItem_checkOut.php
print again the same data part that the div contains(here assumed as table.so print the table in your php file again).
Upvotes: 1
Reputation: 1143
Remove the "window.location.reload();" line from your success callback.
This line is telling your ajax call to reload the window after it has been successfully executed.
Upvotes: 1