Problem is very clear your route allowed only POST method but you are using $.getJSON
it is a GET method if you want to use POST method
Try $.post
$.post('/list_comments', {
a: $('li[id="id"]').val()
}, function(data) {
//data contains the JSON object
}, "json");
@app.route('/list_comments', methods=['POST'])
@login_required
def listComments():
a = request.form.get('a')
comments = getComments(a)
return jsonify(comments)
OR if you want to use GET method
Try this
@app.route('/list_comments', methods=['GET'])
@login_required
def listComments():
a = request.args.get('a', 0, type=int)
comments = getComments(a)
return jsonify(comments)