How to stop redirect on-click wishlist icon

My wishlist code:

<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** @var MagentoWishlistBlockCatalogProductProductListItemAddToWishlist $block */ ?> <?php if ($block->getWishlistHelper()->isAllow()) : ?> <a href="#" class="action towishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>" aria-label="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>" data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($block->getProduct()) ?>' data-action="add-to-wishlist" role="button"> <img class="whislist-icon product-id-<?php echo $block->getProduct()->getId();?>" src="<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/whislist_icon.jpg'); ?>" /> <span><?= $block->escapeHtml(__('Add to Wish List')) ?></span> </a> <?php endif; ?> <?php $_objectManager = MagentoFrameworkAppObjectManager::getInstance(); $storeManager = $_objectManager->get('MagentoStoreModelStoreManagerInterface'); $currentStore = $storeManager->getStore(); $mediaUrl = $currentStore->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA); $wishimage = $mediaUrl."after_added.jpg"; ?> <script> require(['jquery'], function($){ jQuery.ajax({ url: '<?php echo $this->getUrl('addtowish/index/wishlist') ?>', method: 'get', dataType: 'json', success: function(data) { var wislistAddesCheckData = data; var itemLenth = wislistAddesCheckData.items.length; for(i=0;i<itemLenth; i++){ var wislistAddedProductId = wislistAddesCheckData.items[i].product_id; $(".product-id-"+wislistAddedProductId).attr('src','<?php echo $wishimage ; ?>'); } } }); }); </script> 

Now, if click the wishlist icon its redirects to the wishlist landing page, how to stop that?

submitted by /u/aveeva7
[link] [comments]