Skip to content
Advertisement

Using innerHTML to include HTML Django page not work

I am trying to include an HTML when a button is clicked in a Django project but the error a Uncaught SyntaxError: Invalid or unexpected token

Here is the Javascript:

document.getElementById("workout_table").innerHTML = '{% include 'app/log_form.html' %}';

The error showing is at this line of code as if the include code is not there at all. enter image description here

My question: How can I add this code through javascript and avoid this error

Advertisement

Answer

Try changing quotation marks to Grave accent :

document.getElementById("workout_table").innerHTML = `{% include 'app/log_form.html' %}`;
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement