A
A
Alexander2015-03-11 20:20:45
JavaScript
Alexander, 2015-03-11 20:20:45

How to change a variable on a page without reloading?

Good evening, today I wrote a parser that takes the dollar rate from a given source and writes it to a variable, I pass this variable to the template using Flask and it is displayed on the site, so {{ dollar }}, the question is, how can I do it so that the value displayed on the page changes in real time, and not after reloading the page?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav, 2015-03-11
@RGV

Ajax

G
George, 2015-03-11
@BATC0H

The simplest thing is to request an update from the server using Javascript via Ajax at some frequency (yes, at least once a second).
If you absolutely need to receive updates as they become available, you can use SSE or WebSockets, but here everything is already a little more complicated.
There is a presentation in English, which just describes all the methods and gives examples of server code for Flask.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question