0
I make the population 4 HTML select with Ajax, however I’m having trouble returning the files, I tried to do it asynchronously only it was not good because the user can see each select being populated in order(besides the delay is ugly to see), when I changed my function to asynchronous and my Ajax also, I can not return data, example.
function GetDropdownList(table)
{
    var DDItems;
    function GetDropdownList_AjaxCallBack(data) {
        DDItems = data;
    };
    $.ajax({
        type: "POST",
        url: "/Ajax/GetDropdownList",
        dataType: "json",
        data: {
            table: table
        },
        async: true
    })
    .done(function (data) {
        GetDropdownList_AjaxCallBack(data);
    })
    .fail(function (XMLHttpRequest, textStatus, errorThrown) {
        console.log(errorThrown);
        });
    return DDItems;
}
async function PopulateDropDown(dropdownID) {
    var dropdownItems = GetDropdownList(dropdownID);
    console.log(dropdownItems.items);      
}
PopulateDropDown("LicenseDocs_Midia");
PopulateDropDown("LicenseDocs_Regiao");
PopulateDropDown("LicenseDocs_Prazo");
PopulateDropDown("LicenseDocs_Use");
In the console log. get the following JS error:
Typeerror: dropdownItems is Undefined
I researched that to return objects from asynchronous Ajax just create a Callback, but it is not working and I can’t find a solution...