I do not get the javascript function in jquery of a JSP

0

I have a js file that contains this function:

function Relleno(variable){
      if(variable!=""){
    return true
}
else{
    return false;
}

}

Then I have a JSP where I use this function in my Jquery

<script src="../js/funciones.js"></script>
<script
          src="https://code.jquery.com/jquery-3.3.1.js"
          integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
          crossorigin="anonymous">
</script>

<script>

$(document).ready(function(){
 var nombre = "";
 if(Relleno(nombre)){
    alert("Esta relleno");
 }
 else{
    alert("Vacio");
 }

</script>

And when I try it, I do not get any alerts. The route seems to me to be fine. I call functions.js from Productos.jsp, attached image.

Thank you very much in advance.

    
asked by bsg 27.10.2018 в 12:03
source

2 answers

0
<script src="<c:url value = "js/funciones.js"/>"></script>

try this, and your contenedores folder should be within the WEB-INF , it usually goes through this out of context

    
answered by 27.10.2018 в 17:06
0

Publishing the solution is quite long, so your Contenedores folder leaves it at the level of index that is outside of the WEB-INF folder and thus imports your <script src="js/funciones.js"></script> direct scripts into the archive folder without the ../ even your contenedores
<a href="contenedores/Productos.jsp">Productos</a> sufficient for the Hola Mundo and import first the jquery

The return is a concept of servlet and juggle with the XML of configuration, I recommend you check the box of Spring Framework when creating a Nuevo Proyecto , it sorts and configures everything for you

    
answered by 27.10.2018 в 18:40