JSFiddle - React, Tailwind, and code Playground
HTML
<div class="document">
</div>
JavaScript
var equipValue = [];
var selectedTrucks = [];
selectedTrucks.push("131-00004131");
selectedTrucks.push("131-00004132");
for (var i in selectedTrucks) {
(function(i) {
// ajax request
$.ajax({
async: true,
cache: false,
type: 'post',
url: '/echo/json/',
data: {
json: '{"n":"response","txt":"text here"}'
}
}).done(function(data) {
if (data != null) {
equipValue[i] = data;
$('.document').append(i + " -> " + equipValue[i].n + " " + equipValue[i].txt + "<br>");
}
});
})(i);
}