Answer the question
In order to leave comments, you need to log in
How to load data into twig template via ajax?
There is a twig template, data is passed there
render('template.html.twig', ['data' => $data])
in which the data is processed, looks something like this
{{ data.header }}
{% for item in data.items %}
{{ item }}
{% endfor %}
How can I pass json of the data type so that it gets into the template?
I can insert the title, but what about iterating over the array so as not to draw tags in ajax like
success: function (data) {
for (...)
...
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question