getting jquery post data null inside python flask -
jquery ajax call
api_key=$('#acesskey').val(); secret_key=$('#sacesskey').val(); provider_name = $('#cname').val(); $.ajax({ type: "post", data: {api_key:api_key,secret_key:secret_key,provider_name:provider_name}, url: $script_root + "/login", contenttype: "application/json; charset=utf-8", success: function(data) { alert(data.status); if(data.status == "true") { custom_ready(); } } }); python flask code
provider_name=request.args.get('provider_name') api_key=request.args.get('api_key') secret_key=request.args.get('secret_key') print provider_name print api_key print secret_key output
none
none
none
request.args contains query string parameters (like bar in /foo?bar=42). doing post request , want in request.form.
see here: http://flask.pocoo.org/docs/quickstart/#the-request-object
Comments
Post a Comment