JSFiddle - React, Tailwind, and code Playground

by karlovac

JavaScript

//This handles the queues    
(function($) {
    var ajaxQueue = $({});
    
    $.ajaxQueue = function(ajaxOpts) {
        var oldComplete = ajaxOpts.complete;
        ajaxQueue.queue(function(next) {
            ajaxOpts.complete = function() {
                if (oldComplete) oldComplete.apply(this, arguments);
                next();
            };
            $.ajax(ajaxOpts);
        });
    };
    
})(jQuery);

// Queue the calls to run one at a time
var productDataUrl = 'https://s3.amazonaws.com/fluid-configure-published/prod/prod/customers/c1475/configureHtml/products/p_20147/configureHtmlProductData.js';
var productId = '20147';

jQuery.ajaxQueue({
    url: productDataUrl,
    dataType: 'jsonp',
    async:true,
    jsonpCallback: 'configure_c1475_p_'+productId+'_jsonp_callback',
    success: function( data ) {
        alert('SUCCESS - Data Loaded');
        product_facets = data.productFacets;      
        window.Fi18n = {};
    },
    error: function( err ) {
        console.log("Validate product timeout issue");
        return false;
    }
});