I\'m trying to use a jquery varaible inside a twig template to send by ajax, but I can\'t access to the jquery variable inside the twig:
My code is:
The problem is that Twig is launched before than JavaScript and the variable "id_emergencia" is not recognized by Twig. You could do a trick. You can put a string, as a parameter and then, in the JavaScript code, you replace the string with the value of your variable. In this way, you will always have the correct url before your AJAX petition is launched.
You could do something like this: