I'm trying to send data in a dictionary format from the client side JavaScript to the server back end via AJAX. It is working, however the data received on the Python end is not what I expected.
>>> b'new+class=some_valaue&document+id=1234567'
What I am expecting back is:
{'new class': 'some_value', 'document id': 1234567}
My javascript
$.ajax({
url: '/reclassify',
data: {'new class': 'some_value',
'document id': 1234567,},
type: 'POST',
success: function(response){
console.log(response);
},
error: function(error){
console.log(error);
}
});
My Python/Flask
@app.route('/reclassify', methods=['POST'])
def reclassify():
data = request.get_data()
print(data)
return 'success'
I don't have any if POST statements yet because I'm still trying to figure out how to get the data sent across in the right format.