I have a web application that gets dynamic data from Flask when a select element from HTML is changed. of course that is done via jquer
If you are sending data using json you don't need to use Jinja2. You can simply try something like this:
@app.route('/_get_content/')
def _get_content():
option_id = request.form['option_id']
all_options = models.Content.query.filter_by(id=option_id)
return jsonify({'data': [option.name for option in all_options]})
or define a method in your model something like to_json that returns a field or dictionary or ... and call it in your view.
@app.route('/_get_content/')
def _get_content():
option_id = request.form['option_id']
all_options = models.Content.query.filter_by(id=option_id)
return jsonify({'data': [option.to_json() for option in all_options]})