I would like to assign the value of a Javascript variable to a twig variable like this :
$(".change-mod").click(function(){
var id=$(this).attr("id");
{{% set page = 'here i want to assign id to page' %}}
});
How can I do it?
Bare in mind, that it will not really allow you to assign javascript variables to twig variables, but it will allow you to generate paths on the client side as you can read here http://symfony.com/doc/current/book/routing.html#generating-urls , the documentation points to a bundle, that lets you do exactly that https://github.com/FriendsOfSymfony/FOSJsRoutingBundle , it may be even possible to assign javascript variables to twigs, but that is not what this bundle does.
AJAXrequest but, needless to say, anyTwigvariable is volatile as it will expire at the end of the request...