I need the values in dropdown Html pre-updated/dynamically populated whenever window onloads/loads from flask.
The url /get_data
return list for dropdown values.
@app.route('/get_data' ,methods=["GET"])
@login_required
def getData():
data = ['apple','banana','cherry']
return jsonify({"getdata":data})
The dropdown which needed to be dynamically updated when window onloads.
<div class="col">
<select class="browser" id="fruits">
<option selected> Select Below Fruits</option>
</select>
</div>
How do I proceed with this?
What i have tried:
I'm able to get data from dropdown(dropdown in which exists and its values) and send it to page
and able to return it back through render_template
- {{ value }}
But in above case i'm not able to populate the data in dropdown list to get its value?
function fetch_data(){
let data = $("#fruits").val();
axios({
method:"get",
url:"/page/1",
params: {
data
}
}).then(function (response) {
$(document.body).html(response.data)
});
}