You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to load an external json on the example. Seems i could load the json and create the needed html from it. But the reste of SlotMachine got a problem slot-machine.js:72 Uncaught (in promise) TypeError: Cannot read property 'cloneNode' of undefined at SlotMachine._wrapTiles (slot-machine.js:72) at new SlotMachine (slot-machine.js:40) at secondFunction (tirage.html:133)
I think that the slotMachine have to wait until the json is read and added to the HTML but I can't find a way to make it works.
function readTextFile(file, callback) {
var rawFile = new XMLHttpRequest();
rawFile.overrideMimeType("application/json");
rawFile.open("GET", file, true);
rawFile.onreadystatechange = function() {
if (rawFile.readyState === 4 && rawFile.status == "200") {
callback(rawFile.responseText);
}
}
rawFile.send(null);
}
async function firstFunction(){
readTextFile("data.json", function(text){
var data = JSON.parse(text);
console.log(data);
var string ="";
for (i in data) {
string +='<div class="contest text-center" style="width: 100%; height: 100px; display: flex; align-items: center; justify-content: space-around;">'+data[i].name+'<\/div>';
};
document.getElementById('machine1').innerHTML =string
});
}
I tried to load an external json on the example. Seems i could load the json and create the needed html from it. But the reste of SlotMachine got a problem
slot-machine.js:72 Uncaught (in promise) TypeError: Cannot read property 'cloneNode' of undefined at SlotMachine._wrapTiles (slot-machine.js:72) at new SlotMachine (slot-machine.js:40) at secondFunction (tirage.html:133)
I think that the slotMachine have to wait until the json is read and added to the HTML but I can't find a way to make it works.
And after
What I am doing wrong to load the list from external json ? Best regards
The text was updated successfully, but these errors were encountered: