After receiving an Ajax POST by the server I would like to render a specific template but the template isn't rendered, no errors, nothing. I presume it is something to do with receiving a POST?. Any ideas on what the problem could be?
Javascript:
function sendAjax(stringifiedData){
var csrfToken = document.getElementById("csrf_token").getAttribute("content");
var xhr = new XMLHttpRequest();
xhr.open('POST', '/completed/');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(stringifiedData);
}
Flask server:
@app.route('/completed/', methods=['POST'])
def completed():
data = request.json['data']
logger.debug("data:{0}".format(data)) #This logs OK
return render_template('index.html') #Doesn't render