I want to use jQuery to send JSON data to a Flask route. However, request.get_json()
gives an error. Why doesn't this work?
my_array = {"student_data":{"actual_data":12,"sheet_data":23,"age":"20"},"teacher_data":{"actual_data":193,"sheet_data":203,"age":"40"},"school_data":{"actual_data":593,"sheet_data":29,"age":"49"}};
$.ajax({
url: '/submit_method',
data: my_array,
contentType: 'application/json; charset=utf-8',
type : 'GET',
async: 'false',
success: function (serverResponse) {
}
});
@app.route('/submit_method', methods=['GET'])
def submit_method():
k = request.get_json()
return ''