Reputation: 1642
My "success" response seems to be firing too fast, so I've been forced to go from this...
$('.hs_cart button').click(function(){
$.get($(this).attr('url'), {
success: function(){
refresh_mini_cart();
}
});
});
to this...
$('.hs_cart button').click(function(){
$.get($(this).attr('url'), {
success: function(){
setTimeout(function(){
refresh_mini_cart();
}, 5000);
}
});
});
I've also tried the following but am receiving a "404 not found"...
$('.hs_cart button').click(function(){
$.get({
url: $(this).attr('url'),
success: function(){
refresh_mini_cart();
}
});
});
What am I doing wrong where I'm having to insert a setTimeout??
This is the Woocommerce function I am attempting to fire...
function refresh_mini_cart(){
$.ajax($fragment_refresh).done(function(response){
if(response.cart_hash.length !== 0)
return true;
});
}
Upvotes: 1
Views: 1168
Reputation: 8941
Let's simplify your $.get()
a bit. Try the below code.
$('.hs_cart button').click(function(){
$.get($(this).attr('url'), function() {
refresh_mini_cart();
});
});
Your issue was that your syntax for $.get()
wasn't correct.
Upvotes: 1