I have this code:
var myOptions = '<option value=""></option>';
$.getJSON("/users/GetUserAccesses/" + username, function (UserAccesses) {
$.each(UserAccesses, function (key, val) {
$.getJSON("/users/GetCommunities", function (Communities) {
$.each(Communities, function (key1, val1) {
if (parseInt(val1.id) == parseInt(val.community)) {
myOptions = myOptions + '<option selected="selected" value="' + val1.id + '">' + val1.name + '</option>';
} else {
myOptions = myOptions + '<option value="' + val1.id + '">' + val1.name + '</option>';
}
});
});
});
});
alert(myOptions);
The alert is returning <option value=""></option>
? What am I missing? I have placed the alert in different places before the })
and the results are shown.