Magento – Add product to wishlist without reloading page

ajaxwishlist

How can I add a product to my wishlist without the page reloading? I tried the answer on this but it still reloads the page.

Using

return false;

and

event.preventDefault();

stops the link from adding the product to the wishlist altogether on my homepage while it doesn't affect the link in the single product pages (still reloads but adds the product to wishlist).

How do I pull this off? I want a pop-up for logged in customers to confirm that the product is added to wishlist but I don't know how to use AJAX on Magento's wishlist.

Here's my development site: LINK

Best Answer

One way to do this would be to create your own controller and action that will take the same information add to the wishlist but simply return a json response with success or a failure message.

In this way you can skip all the redirect stuff and work with a simply ajax action.

Related Topic