I have an AJAX request which successfully returns a string in the format of a list. (Done using flask)
$.ajax({
type: 'POST',
url: "{{ url_for('PatientDashboard') }}",
data: {Date: dateText},
dataType: "text",
success: function (Data) {
console.log(Data)
var Data = Data
}
});
The output in the console is a string of ["Item1", "Item2", "Item3"]
which I need to manipulate by converting this into a list and iterating through.
The desired result is to be able to do this in my HTML code.
{% for i in AppointmentList %>
<a href="#">{{ i }}</a>
{% endfor %}
Which should output a series of links of Item1
, Item2
, Item3
- all separate links.
In summary, how do I access the variable Data
in the HTML part where I am able to use Jinja2 to manipulate it?
Thanks in advance.
EDIT:
Solved by passing variables through a flask render_template.