In my main python file, I have the following code.
@app.route('/accounts/test/learn/medium')
def medium():
word = random.choice(os.listdir("characters/"))
return render_template('accounts/test/medium.html', word=word)
My HTML Template "Medium" has a div called "character" which contains the word.
<div id="character" style="font-weight:bold;color:red" >{{ word }}</div>
My Javascript file, which I call body onLoad tries to set the png file for the word/character.
currentWord = document.getElementById("character").value
if(document.getElementById("characterPNG")!=null){
document.getElementById("characterPNG").src = "../../../style/images/characters/png/" +currentWord+ ".png";
When I run the application, Python sets the word in my HTML I can see that, but JavaScript, can't see the value of character. It rather say's
Failed to load resource: the server responded with a status of http://path/undefined.png
Do you have any suggestions what might be wrong? Is it the sequence?