Let's say I have a list of books I want to render in a certain way with JavaScript, as opposed to just doing something like the following;
{% for book in books %}
<div class="book-container">
<div class="title">{{ book.title }}</div>
<div class="author">{{ book.author }}</div>
</div>
{% endfor %}
I want to load the json representation of books into a JavaScript variable (perhaps a list of Book objects I've defined in my client side code) and render it in a more "fancy" way using JavaScript.
Anyways, I was thinking of sending a post request on page load to get the data and loading it into a variable. Is there a better way to do this? These are my initial naive guesses.
EDIT: In essence, I want to learn of a legitimate/recommended way to get a context server side and load it into a JavaScript variable client-side on page load.