I am making an AJAX request via JavaScript:
$.ajax({
url: '/available_data',
type: 'POST',
headers: {
'X-CSRFToken': csrf_token
},
data: JSON.stringify(data),
contentType: 'application/json',
success: function(response) {
},
error: function(xhr, status, error) {
console.log(xhr)
console.log(status)
console.log(error)
}
});
As a response to this POST request made by the client, I want to render an HTML template via flask:
if request.is_json:
return render_template('my_template')
I have tried making a POST request like this via javascript:
var xhr = new XMLHttpRequest();
xhr.open("POST", "/available_data");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader('X-CSRFToken', csrf_token);
xhr.send(JSON.stringify(data));
But it still does not let me directly render a html template via flask
Via Active questions tagged javascript - Stack Overflow https://ift.tt/eGW5Xmx
Comments
Post a Comment