-1

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.

Sphinx
  • 10,519
  • 2
  • 27
  • 45
Henry Henrinson
  • 5,203
  • 7
  • 44
  • 76
  • I don't even know what tags would be appropriate, as a I am not familiar with the applicable technologies. If anyone thinks they can amend them, please go ahead. – Henry Henrinson Mar 09 '18 at 22:58
  • 1
    check this [Bootstrap 3 - How to load content in modal body via AJAX?](https://stackoverflow.com/questions/19663555/bootstrap-3-how-to-load-content-in-modal-body-via-ajax) – Sphinx Mar 09 '18 at 23:04

1 Answers1

1

Since there is no code, I will explain what you need to do:

1 - Have a function on a specific URL that will receive a POST, do the query, and return the result (on a JSON)

2 - Have an Ajax post on your page that is triggered when you click on the word. That will make the request to your function (#1), and render the result on the popover.

Let me know if you need more details

Walucas
  • 2,549
  • 1
  • 21
  • 44