JSFiddle - React, Tailwind, and code Playground
HTML
<select id="dropdownBox">
</select>
JavaScript
var items = [1, 2, 3, 4, 6, 7, 8, 9];
var promises = items.map((e) => {
return $.ajax({
type: 'post',
url: "/echo/json/",
dataType: "json",
data: { json: JSON.stringify({ id: e}) }
}).then((data) => {
var html = ''
if (data.id > 3) {
html += "<option value='" + data.id + "'>" + e + "</option>";
}
return html;
});
});
Promise.all(promises).then((res) => {
$("#dropdownBox").html(res.join(''));
});