My Javascript stopped passing variables when I use User-Friendly URL

Asked

Viewed 42 times

-2

I use the following Javascript, and it stopped passing the variables by the parameters when I used Friendly URL.

For example cidade='+$('#cidades').val() failed to take the variable value.

<script type="text/javascript">
        var idcl = document.getElementById('idcl').value;
        $(document).ready(function(){
            $('#estados').change(function(){
                $('#cidades').load('cidades.php?estado='+$('#estados').val()+'&cliente='+idcl);
            });
            $('#cidades').change(function(){
                $('#negocios').load('negocio.php?cidade='+$('#cidades').val()+'&cliente='+idcl+'&estados='+$('#estados').val());
            });
            $('#negocios').change(function(){
                $('#tipos').load('tipo.php?negocio='+$('#negocios').val()+'&cidade='+$('#cidades').val()+'&cliente='+idcl+'&estados='+$('#estados').val());
            });
            $('#tipos').change(function(){
                $('#dormitorios').load('dormitorios.php?tipo='+$('#tipos').val()+'&cliente='+idcl);
            });
        });

    </script>
  • Need to be more clear in your question, the values come via GET and are stored in Hidden input fields? What is the htaccess rule ? None of this is in the question and the problem if you report it is with the friendly url should not be in this code snippet posted.

1 answer

-1

Try to pass as string template: Template string - Javascript

Open a string with

`

Inside the call with template

${variable}

It would be something like:

$('#cidades').load(`cidades.php?estado=${('#estados').val()}&cliente=${idcl}`);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.