Now I am using JavaScript function coded as follows:
self.fillSelect = function (key) { 
             html = "<option value =''>choose</option>";
            self.getGroupOptions(key, function (res) {
                for (let a = 0; a < res.length; a++) {
                    html += "<option value = '" + res[a].Code_Name + "'>" + res[a].Code_Name + "</option>";
                   
                }
            }, function (err) {
            });
            return html;
        }
As I know or understand the html variable is a global variable and can be accessed in any place in the function. In this function this logic happens after the return statement. This function just returns
<option value =''>choose</option>
then enters the loop with no result...why is that happening??
self.getGroupOptions()
This function is a jQuery AJAX request to get options from database
 
    