My Javascript post url is as shown below with %20 in between i.e. spaces, when I'm trying to access this URL with Flask the search variable is shown as type None.
Am I parsing the url parameter cmpname correctly inside showMapMArker() function, Not sure about it.
POST /getLatLong/Ogden%20UT%20844
Python:
@app.route('/getLatLong/<cmpname>',methods=['GET','POST'])
def showMapMarker(cmpname):
# print("Inside ShowMarker")
search = request.args.get(cmpname)
//do something with search string
return jsonify(search)
Javascript:
function myFunction() {
var cmpCanName = document.getElementById("autocomplete").value;
var cmpCanAddress = document.getElementById("autocompletetwo").value;
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "/getLatLong/"+cmpCanAddress, true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send();
var response = JSON.parse(xhttp.responseText);
}