This question already has an answer here:
Problem:
I am trying to display displayName. However it is inside of this asynchronous request and I'm unsure how to properly to display it. When moving the 2nd & 3rd to last lines after the final }); the innerHTML displays without displayName. Thanks!
Error Message:
Uncaught TypeError: Cannot set property 'innerHTML' of null
Code:
query.get(winner).then(function(results) {
var name = results.get("name");
var lname = results.get("lastName");
displayName = (name + " " + lname.charAt(0));
console.log (displayName);
document.getElementById(gameIds[i] + "_topic ").innerHTML = "Sorry, " + displayName + ". won.";
});
Aucun commentaire:
Enregistrer un commentaire