M
M
Morrowind2021-04-08 16:09:42
AJAX
Morrowind, 2021-04-08 16:09:42

How to make ajax request in jqwery?

Hello.
I can't figure out how to make a primitive request to flask from a web page.
There is a button and plain text. It is necessary to dynamically access a variable without reloading the page, which contains a new value each time it is accessed.
Please show an example of how to do this primitively on jqwery.

<div class="container">
           <p class="lead" > {{hook}} </p>
           button type="button" class="btn btn-outline-secondary" >ROLL</button>
       </div>


on the FLASK side

app = Flask(__name__)

@app.route('/')
def hello_world():
    hook = result # тут содержится функция которая рандомно при обрезании выплевывает новое значение.
    return render_template('index.html', hook = hook)
.....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WebEagle, 2021-04-08
@hekkaaa

Don't need jQuery, switch to pure JS
fetch tools
https://learn.javascript.ru/fetch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question