Reputation: 3375
I have url which looks like example.com/admin/category.php?parent=368
When I click to see second page it becomes like example.com/admin/category.php?pageno=2&parent=257
When I delete product from category I want to redirect me back to same page and I've using
header('Location: ' . $_SERVER['HTTP_REFERER']);
This works when I'm on first page but if I'm on second or another page ?pageno=2&parent=257 it redirects me to &parent=... it's loosing pageno=...
I've tried a lot of solutions here on so but all redirect me back to parent.
I've tried also like this:
header("location:javascript://history.go(-1)");
but this doesn't refresh the page and I need to refresh it in order to see the result.
Actually ideally should refresh the page and stay on same page..
function deleteproduct(prodid) {
if(confirm('Are you sure you want to delete this product')) {
window.location = "del_product.php?act=del&masterCategory=<?=$parent?>&subCategory=<?=$child?>&productID="+prodid;
}
}
Upvotes: 1
Views: 104
Reputation: 12937
Instead of HTTP_REFERRER
you can use location.reload()
after deleting a item to refresh the changed contents. Below is the example:
function deleteproduct(prod) {
if(confirm('Are you sure you want to delete this product')) {
$.get( "del_product.php", { act: "del",
masterCategory: "<?php echo $parent; ?>",
subCategory: "<?php echo $child; ?>",
productID: prodid } )
.done(function( data ) {
alert( "Data Loaded: " + data );
location.reload();
});
}
}
Upvotes: 2