I am developing a web system with Symfony 3.4. I have a function that must execute an ajax call to a controller and use the jquery function for that purpose. I'm having problems using the {{path ('')}} in the url The ajax call is the following in my file turnos_filtrar.twig.js :
$.ajax
({
async:true,
method: 'GET',
url: "{{ path('turnos_listar') }}",
//url: '/turnos/listar',
data: datos,
dataType: 'json',
beforeSend:iniciaEnvioTurnos,
success: cargarFilasTurnos,
timeout:11500,
error : function()
{
//desbloqueo la pagina
$.unblockUI();
//accedo al alert
//var error = document.getElementById('error-turno');
//seteo el msj
//error.innerHTML = '<p>Error de conexión, por favor intente registrarse nuevamente más tarde</p>';
//muestro
//$('#error-turno').show();
alert('ERROR DE CONEXIÓN, INTENTE NUEVAMENTE MAS TARDE');
}
});
The route you are consulting is / shifts / listing and debugging: routing in console I get
turnos_listar GET ANY ANY /turnos/listar
The call works if I use the line that is commented:
//url: '/turnos/listar',
But it does not work when I use the {{path ('')}}, I am interested in using it for changes in the routing, it is not necessary to manually change the js files. Thank you! Your help is welcome! Cristian