I have a page showing a large number of words. For each word I can run a non-trivial database query (left joining a few tables, for example). I would like the result of that query to be shown in a popover when I click on the word.
Running all the queries when the page is generated is not really an option as it would take a long time and be a bit wasteful.
Ideally, I would have a setup where, when clicking on the word, I somehow send a query to the server which would respond with the query result. I would then display the query result in the popover.
I am a beginner when it comes to webdev, but I imagine I am not the first person to have this use-case.
What would be the easiest way of obtaining the effect I have described above?
I am using popover.js (via Bootstrap 4). The server is written in Django, if it matters.