$(function(){
$('.delete').click(function(e){
$.ajax({
url:'/polls/cart__Delete/'+$(this).attr('data-id'),
success: function(data){
$('.modal-body').html(data);
parent.location.reload(true);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {alert('Loading failed!!'); }
});
e.preventDefault();
});
});
Only refresh parent page
-
30-06-2023 - |
Question
I am using a modal to show the shopping cart. Users can delete items in the modal. So what I want to do is that after they delete an item, the parent page will be refreshed and the modal should still show up. Right now, After I click on the "delete button" in the modal, the parent page will be refreshed but the modal CLOSES UP.
My code:
$(function(){
$('.delete').click(function(){
$.ajax({
url:'/polls/cart__Delete/'+$(this).attr('data-id'),
success: function(data){
$('.modal-body').html(data);
parent.location.reload(true);
},
});
});
});
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow