I'm trying to send a simple POST request containing some data. I'm processing the request in flask and trying to return the same data. But it's always returning 'None'.
AJAX
$(function(){
$('.btn').click(function(){
var roll_no = $(this).parent().parent().children(':first-child').html();
$.ajax({
url: '/delete_student',
data: {id: roll_no},
type: 'POST',
dataType: "text",
success: function(response){
console.log(response);
},
error: function(error){
console.log(error);
}
});
});
});
FLASK
@app.route('/delete_student',methods=['GET','POST'])
def delete_student():
if request.method=='POST':
roll_no = request.args.get("id")
return str(roll_no)