Loading Yotpo Reviews with AJAX

      Loading Yotpo Reviews with AJAX


        Article Summary

        Products


        Reviews
        Supported plans

        Free, Starter, Pro, Premium, Enterprise

        eCommerce Platform

        N/A

        Yotpo's on-site assets and features load asynchronously. This means that the various widgets will only be loaded once on the initial page load, and will be then ignored by any AJAX scripts running on the page. As such, AJAX-based elements such as endless scroll pages or custom product pages will only appear on the initial page load. 

        In this article, you'll learn how to load Yotpo Reviews with AJAX.

        Please note:
        Due to advanced requirements, these codes should only be added by an experienced developer.

        Loading Yotpo with AJAX

        To properly display Yotpo on-site assets on pages which dynamically update content (without reloading the entire page), it is necessary to reinitialize Yotpo assets every time new content is loaded.

        To automatically update and re-initiate Yotpo assets, the Javascript below must be added to callback functions when new content is loaded.

        var api = new Yotpo.API(yotpo);
        api.refreshWidgets();

        In addition to updating the callback functions, be sure to update the relevant widgets attributes per product:

        For example:

        • Product ID
        • Product URL
        • Product Name
        • Product Description

        Upon refreshing the page content, on-site assets will be updated to reflect the correct data attributes.



        Was this article helpful?