Do not enter my .js file when loading the website? [closed]

0

My problem is that I am currently trying to call an onclic type function through a button, but when I click on the button in the browser console it appears that it is not defined:

I miss it:

Uncaught ReferenceError: siguiente_promo is not defined
    at HTMLButtonElement.onclick (index.php:227)

Button code:

  <button type="button"  name="next" class="next action-button" value="Siguiente" onclick="siguiente_promo(0);" >
  Siguiente &nbsp <i class="fa fa-chevron-right"></i></button> 

I mark that error because when I want to read the .js file it does not read what is inside.

Link code:

<script src="vista/plugin/form/archivo.js" type="text/javascript"></script>

Code at the beginning of the .js file:

$( document ).ready(function() {
    console.log( "formulario de promotor" );
    alert("Entro");
    var correcto=0;
});

The document.ready does not run it, at least the one in the file where the function is, I already erase cookies from my browsers and test it in three different browsers. The address is correct because before it worked

    
asked by David 14.07.2017 в 21:37
source

2 answers

0

I already found the error, it was a finger error, the problem is that I had this line of code in file .js

mensajeValidacion("cmbEstado_promotor","iderror_form"3,);

So if I entered my .js file but when I realized that there was a syntax error, it would go out of my way, discarding what I had read from my file.

    
answered by 14.07.2017 / 22:00
source
0
  • First Verify that link if you have the correct route
  • <script src="vista/plugin/form/archivo.js" type="text/javascript"></script>
    
  • This code.
  • $( document ).ready(function() {
    /// dentro código se utiliza cuando quieres que se ejecute algo, cuando se carge el DOM.
    });
    
  • Outside of it you would generate your onclick() function would be like this.
  • $( document ).ready(function() {
      /// dentro codigo que quieres que se ejecute automaticamentecuando se carge el DOM
    });
    function siguiente_promo(dato){
      // tu codigo que se ejecute en onclick() ejemplo:
      alert("onclick ejecutado correctamente");
    }
    
        
    answered by 14.07.2017 в 21:50