JSFiddle - React, Tailwind, and code Playground

by rmurphey

JavaScript

var req1 = $.ajax('/echo/json/', {
    type: 'POST',
    data: {
        json: JSON.stringify({ foo: 'bar' }),
    }
});

var req2 = $.ajax('/echo/json/', {
    type: 'POST',
    data: {
        json: JSON.stringify({ foo: 'baz' }),
    }
});

/*

THIS DOES NOT WORK 

$.when([ req1, req2 ]).then(function() {
    console.log(arguments);
});

*/

$.when.apply($, [ req1, req2 ]).then(function(result1, result2) {
    console.log(result1, result2);
});