JSFiddle - React, Tailwind, and code Playground

by guest271314

HTML

<pre id="results"></pre>

JavaScript

var results = $("#results");
var request = function (url, data) {
    return $.post(url, {
        json: JSON.stringify(data)
    })
}, settings = [
    ["/echo/json/", "success1"], // `success`
    ["/echo/jsons/", "error1"], // `error`
    ["/echo/json/", "success2"], // `success`
    ["/echo/jsons/", "error2"], // `error`
    ["/echo/json/", "success3"] // `success`
];
(function ($) {
    $.when.all = whenAll;
    function whenAll(arr) {
        "use strict";
        var deferred = new $.Deferred(),
            args = !! arr ? $.isArray(arr) ? arr : Array.prototype.slice.call(arguments).map(function (p) {
                return p.hasOwnProperty("promise") ? p : new $.Deferred().resolve(p, null, deferred.promise())
            }) : [deferred.resolve(deferred.promise())],
            promises = {
                "success": [],
                  "error": []
            }, doneCallback = function (res) {
                promises[this.state() === "resolved" || res.textStatus === "success" ? "success" : "error"].push(res);
                return (promises.success.length + promises.error.length) === args.length ? deferred.resolve(promises) : res
            }, failCallback = function (res) {
                promises[this.state() === "rejected" || res.textStatus === "error" ? "error" : "success"].push(res);
                return (promises.success.length + promises.error.length) === args.length ? deferred.resolve(promises) : res
            };
        $.map(args, function (promise, index) {
            return $.when(promise).always(function (data, textStatus, jqxhr) {
                return (textStatus === "success") ? doneCallback.call(jqxhr, {
                    data: data,
                    textStatus: textStatus ? textStatus : jqxhr.state() === "resolved" ? "success" : "error",
                    jqxhr: jqxhr
                }) : failCallback.call(data, {
                    data: data,
                    textStatus: textStatus,
                    jqxhr:...