Duda Symfony, Ajax, Controller


How can I do what is proposed in this question, but passing a parameter to the controller from the ajax, and then, from the controller, returning to the same view where the ajax is executed that parameter through twig?

This may sound redundant but I do it to get in the view a twig variable whose value is unknown and I get it through a javascript variable in the same view. The same, if they know another way of doing it without having to do all the above, they tell me. Thanks.

asked by Adriana Hernández 05.08.2016 в 22:40

1 answer


If that variable is not going to be modified in the controller and you want to modify the DOM, it is better to make that modification with the same Javascript so you do not waste time with the request. Also, when the request returns there is no way to pass the value to Twig because the page is already compiled.

answered by 19.08.2016 в 21:04