B
B
Bruceee2017-08-13 14:25:55
JavaScript
Bruceee, 2017-08-13 14:25:55

How to call a JS function from Flask?

Can you please tell me how can I call a JS function from the server side?

I imagine how to make AJAX requests to the server from the page itself, but is it possible in the opposite direction?
For example, I want to automatically update some element on the page every 5 seconds, and the data for this element is taken using an ajax call. How can this be implemented?

I tried to make a call from JS in the form of a cycle, but for some reason the changes are not displayed on the page until the entire cycle is completed, and the page just hangs in loading.

Please direct me where to find this information. I saw the comment "They are a way to send messages to clients without having to have a bidirectional connection like SocketIO.", but the commenter didn't say how to do it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Chuvanov, 2017-08-15
@Bruceee

Flask_Sockets or Flask_SocketIO

O
Oleg Gamega, 2017-08-13
@gadfi

long polling or sockets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question