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.
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' %}`;