Difficulty to handle a list with JavaScript

0

I'm having a hard time dealing with a list by javascript would like a tip or help if possible

This is the error I'm taking

  

Array ["AC.FIXA"] sign up: 280: 4
  ReferenceError: $ is not defined [Learn More] register: 282: 4
  Empty string passed to getElementById (). registration
  Empty string passed to getElementById (). registration

and my javascript

<script>
    listaProjeto = "${usuarioBean.listaNomeProjeto}";

    listaProjeto = listaProjeto.replace("[", "")
    listaProjeto = listaProjeto.replace("]", "")
    var teste = listaProjeto.split(",");
    console.log(teste)

    $.each(teste, function(index, value) {
        alert(index + ": " + value);
    });
</script>

As I read above, my jQuery is not installed, but everything is fine.

    
asked by anonymous 07.02.2017 / 12:11

1 answer

1

First, check the ; at the end of the lines.

Following, add jQuery just above your script and check if the error persists, like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script><script>listaProjeto="${usuarioBean.listaNomeProjeto}";

listaProjeto = listaProjeto.replace("[", ""); // <- Ponto e virgula
    
07.02.2017 / 12:36