Title: Possible Ajax Loop Bug
Last modified: August 12, 2020

---

# Possible Ajax Loop Bug

 *  [nxtpixel](https://wordpress.org/support/users/nxtpixel/)
 * (@nxtpixel)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/possible-ajax-loop-bug/)
 * Hi, I have found what appears to be a bug in the free version of Yith WishList
   I think you may be interested in.
 * I am performing an Ajax request on the single product page to load new upsell
   products after a variation change with;
    $(document).on(‘found_variation’, ‘form.
   cart’, function (event, variation) { self.getUpsells(event, variation); });
 * As part of my getUpsells() method, I do $(document).trigger(‘yith_wcwl_reload_fragments’);
   to populate the add to wishlist button on the new products which is handled on
   line 493 of jquery.yith-wcwl.js
 * load_fragments() amongst other things triggers $(document).trigger( ‘yith_wcwl_fragments_loaded’,[
   fragments, data.fragments ] );
 * Which in turn is handled by the following, on lines 502-504 of jquery.yith-wcwl.
   js;
    t.on( ‘yith_wcwl_fragments_loaded’, function( ev ){ $( ‘.variations_form’).
   find( ‘.variations select’ ).last().change(); } );
 * The above lines seem to trigger WooCommerce to reload the variation which in 
   turn triggers my initial method listening on “found_variation” and the whole 
   thing goes into a loop.
 * I can’t see what lines 502 to 504 are needed for and removing them does not seem
   to stop anything from working correctly, is it leftover code?
 * Am I using the correct trigger to populate the wishlist button “yith_wcwl_reload_fragments”
   post ajax event
 * Do you have any advice on whether or not this is the correct way to handle such
   an event?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * (@yithemes)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/possible-ajax-loop-bug/#post-13248509)
 * Hi there
 * thank you for reporting
    We’re applying changes to this very part of the js code,
   because we want to reload ATW button any time a new variation is selected, in
   order to show proper template for currently selected variation
 * Doing these changes, we ended up with the same Ajax loading loop that you described
   
   For this reason we slightly changed handling performed at `yith_wcwl_fragments_loaded`
   event, and we made sure to perform that handler on first page load only
 * In the next version (expected for this week) you’ll find these changes, and hopefully
   this will help you solve your problem too
 *  Thread Starter [nxtpixel](https://wordpress.org/support/users/nxtpixel/)
 * (@nxtpixel)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/possible-ajax-loop-bug/#post-13248550)
 * Hi and thank you for getting back to us so quickly.
    That’s great to know and
   We look forward to your plugin update; if we experience any similar issues we
   will let you know.
 * Many thanks and best regards
 *  Plugin Author [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * (@yithemes)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/possible-ajax-loop-bug/#post-13256235)
 * Hi there
 * Just a quick update to let you know that Wishlist 3.0.12 is out with the modified
   js
    Could you please test it and let me know?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Possible Ajax Loop Bug’ is closed to new replies.

 * ![](https://ps.w.org/yith-woocommerce-wishlist/assets/icon-128x128.gif?rev=3129302)
 * [YITH WooCommerce Wishlist](https://wordpress.org/plugins/yith-woocommerce-wishlist/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-woocommerce-wishlist/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-woocommerce-wishlist/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-woocommerce-wishlist/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-woocommerce-wishlist/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-woocommerce-wishlist/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/possible-ajax-loop-bug/#post-13256235)
 * Status: not resolved