JSFiddle - React, Tailwind, and code Playground

by Alexey Ukolov

JavaScript

function getOrdersPrint() {
    var request = $.ajax({
        type: "POST",
        data: {
            operation: 'getordersprint'
        },
        url: "manager.php",
        dataType: "json",
        success: function (json) {

        }
    });

    request.done(function (response) {

        var subrequests = [];

        $.each(response.ordersprint, function () {

            var id = this['id'];

            subrequests.push($.ajax({
                type: "POST",
                data: {
                    operation: 'getfiles',
                    id_order: id,
                    type: 'print'
                },
                url: "manager.php",
                dataType: "json",
            }));
        });

        $.when.apply(this, subrequests).done(function () {
            var rows = [];

            $.each(arguments, function (index, response) {
                $.each(response[0].files, function () {
                    filesorder = +'<a href="/upload/' + this['name_file'] + '" download="">' + this['name_file'] + '</a><br>';
                });
                
                rows.push('<tr><td colspan="10">' + filesorder + '</td></tr>');
            });

            $('#managerTableOrderPrint').html(rows);
        });
    });
}