You really don't need to get data from ImmutableMultiDict . There are a few errors in what you have that prevent you from simply pulling the response as json data. First, you need to slightly adjust the parameters of your ajax call. You must add to the call type as POST . In addition, datatype should be written as datatype . Your new challenge should be:
var data = {"name":"John Doe","age":"21"}; $.ajax({ type: 'POST', contentType: 'application/json', url: '/post/data', dataType : 'json', data : JSON.stringify(data), success : function(result) { jQuery("#clash").html(result); },error : function(result){ console.log(result); } });
Now the data is actually sent as a mail request with the json type. On the Flask server, we can now read data as information about the son as follows:
@app.route('/post/data',methods=['GET','POST']) def postdata(): jsonData = request.get_json() print jsonData['name'] print jsonData['age'] return "hello world"
This will lead to the successful completion of the printing of John Doe and 21 .
Let me know if this works for you or if you have any further questions!
Edit: you can return success to the ajax call from the bulb as follows:
# include this import at the tomb from flask import jsonify @app.route('/post/data',methods=['GET','POST']) def postdata(): ... return jsonify(success=True, data=jsonData)
source share