I try to send a POST request as I change the select box for my page running on local host.
Here are my codes;
This is my Flask function that shoudl respond to POST
@app.route('/chng_clf', methods=['POST', 'GET'])
def change_clf():
clf_name = flask.request.args.get('clf_name', '')
print clf_name
This is the Jquery code doing AJAX in
<script type="text/javascript">
$("#select_clf").on("change",function() {
$.ajax({
type: "GET"
url: 'chng_clf',
data: {
'clf_name': $(this).val(),
},
success: function(msg){
alert('wow' + msg);
}
error: function(msg){
alert('wow!!' + msg);
}
});
});
</script>
This is the select box in
<select id="select_clf">
<option value="scene">Scene Model</option>
<option value="object">Object Model</option>
<option value="clothes">Clothes Model</option>
<option value="concept">Concept Model </option>
</select>
However for some reason I cannot get any change after I change the select box. Could you point the problem about this code?