I am in the middle of creation of a web application.
In javascript, I make a ajax call to my python script, process and send the result back as response. /process/ is the route to the python script for the processing of values which are sent as json, namely value1 and value2. I send back response as json setting value in key 'result'.
In the success block of ajax, the value is stored in name_value and this should be passed as parameter to the python routing method.
Javascript:
$.ajax({
type: "GET",
url: "/process/",
contentType: "application/json; charset=utf-8",
data: { "value1" : value1,
"value2" : value2
},
success: function(data) {
var name = data.result;
console.log(name);
window.location.href = "{{url_for('/process2', name=name)}}"
}
});
Python script:
app.route("/process2/<name>")
def process2(name):
print name
render_template("user.html", name=name);
I am not receiving the parameter value in this case if parameter is passed in url_for. If I hardcode the parameter, I am able to receive the parameter value in the python script as in,
window.location.href = "{{url_for('/process2', name='helloworld')}}"
Any help is appreciated. Thanks in advance.