I want to use backend data in the js file.
return render(request, "class.html", {'all_classes':all_class})
I want to use it in the JS ‘all_classes’.
I know for the HTML –
<select name="subject_class" type="text" class="form-control" required >
{% for class in all_classes %}
<option value="{{ class.class_name }}">{{ class.class_name }}</option>
{% endfor %}
</select>
but please give me an idea for the javascript.
2
Answers
try this:
in your html page create script tag
you can construct the body of the script tag in the same way