I am attempting to populate a select list with items from my database. I have confirmed (with the use of an "alert()" box) that the jquery .getJSON function is fetching the correct data, but the select list is still not populating.
var selectBox = document.createElement("select");
$.getJSON('optionGrabber.php', function(data) {
$.each(data, function(key, dbValue) {
var option = document.createElement("option");
option.setAttribute("value",dbValue);
selectBox.appendChild(option);
});
});
myDiv.appendChild(selectBox);
Like I said, when I stick an "alert(dbValue);" immediately after the ".each" statement, I get the correct data in the alert pop-ups.