Answer the question
In order to leave comments, you need to log in
How to load table using ajax jquery Flask Python?
Good afternoon.
Flask
#У меня есть функция find, которая возвращает json (в данном случае с одним значением)
@app.route('/_find')
def find():
req = request.args.get('req', 0, type=str)
print(req)
return jsonify(result=req+'!')
@app.route('/')
def index():
return render_template('test.html')
<script type=text/javascript>
$(function() {
$('#find').bind('click', function() {
$.getJSON('/_find', {
req: $('input[name="req"]').val()
}, function(data) {
$("#res").text(data.result);
});
return false;
});
});
</script>
</head>
<body>
<div class="container">
<div>
<form>
<p>
<input type="text" size="5" name="req">
<span id="res"> </span>
</p>
<a href="javascript:void();" id="find">find</a>
</form>
</div>
<ul>
<li>test1</li>
<li>test2</li>
<li>test3</li>
</ul>
Answer the question
In order to leave comments, you need to log in
pcdesign : Thanks for the help!
In this case, it is incorrect to indicate something as a solution.
Therefore, I will write the solution myself - if you do not know the PL - it is better to study its basics first - and then ask questions.
Unfortunately, JavaScript is very different from Python - I don’t know if this is good or bad, and I couldn’t get into it right away, and therefore I was tempted to write to the Toaster.
PS - I will delete the question in the near future.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question