Answer the question
In order to leave comments, you need to log in
How to process ajax request?
Good afternoon, I understand ajax and flask, here I have such a function
@app.route('/ajax', methods=['GET', 'POST'])
def ajax_output():
if request.method == 'POST':
usd = usd_value()
euro = euro_value()
return jsonify(result=[usd, euro])
return render_template('Login.html')
Answer the question
In order to leave comments, you need to log in
Here is an example:
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script>
function check(){
$.post("/ajax", {}, function(data){$("input[name='currency']").val(data)});
}
setInterval(check, 10000);
</script>
<input type="text" name="currency" readonly>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question