export class PizzaController{
static loadData(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
dynamicSelect(xhttp.responseXML);
}
};
xhttp.open("GET", "js/data/pizzadata.xml", true);
xhttp.send();
}
dynamicSelect(xmlDoc){
var doughTypes = [];
let selects = document.getElementById("selects");
let doughSelect = document.createElement("select");
doughSelect.setAttribute("id","dough");
selects.appendChild(doughSelect);
let typeSelect = document.createElement("select");
typeSelect.setAttribute("id","type");
selects.appendChild(typeSelect);
let toppingSelect = document.createElement("select");
toppingSelect.setAttribute("id","topping");
selects.appendChild(toppingSelect);
let x = xmlDoc.getElementsByTagName('DOUGH');
}
}
Im trying to extract data from XML file and create a dynamic selector on webapp. The code works when it is procedural i.e. not "OOP" but, I have to do it this way. PizzaController class is being called by init.js and im calling just loadData. When I tried to console log it showed results so the calling works thus this must be the only problem. I keep getting this error
Uncaught ReferenceError: dynamicSelect is not defined
at XMLHttpRequest.xhttp.onreadystatechange