Ajax canceling onblur and onfocus events

1

I'm getting a call to an ajax (Bootstrap 3 + Html + PHP), what happens is that by putting the $ .ajax function, simply the events do not occur, if I put an alert there events happen normally:

Has anyone ever gone through this? is it some incompatibility with Bootstrap, or is it unknown to me?

<script>

    function proximoCampo(atual, proximo){                // salta campo depois de preencher 
        if(atual.value.length >= atual.maxLength){
            document.getElementById(proximo).focus();
        }
    }

    function buscaProduto(){

        $.ajax({
            type: "POST",
            url: "pdv-produto-ajax.php",
            data: {codigoean: '7891111111111'},
            success: function (data) {
                alert(data.val);
            }
        });

    }

</script>

-------------- HTML -------

<div class="form-group">
    <label class="col-md-4 control-label" for="pdvcodigoean">Código Barras*</label>  
    <div class="col-md-8">
        <input id="pdvcodigoean" name="pdvcodigoean" type="text" placeholder="Código Barras EAN13" 
               maxlength="13" class="form-control input-md" required="" autofocus
               pattern=“^*[0-9]”
               onkeyup="proximoCampo(this, 'pdvquantidade')"
               >
    </div>
</div>


<div class="form-group">
    <label class="col-md-4 control-label" for="pdvquantidade">Quantidade vendida  </label>  
    <div class="col-md-8">
        <input id="pdvquantidade" name="pdvquantidade" type="text" 
               maxlength="13" class="form-control input-md" value="1"
               pattern="[0-9]+(\.[0-9][0-9]?)?" min="0.01" max="9999999.99"
               onfocus="buscaProduto()">
    </div>
</div>    
    
asked by anonymous 13.01.2017 / 00:36

1 answer

1

First of all, remember the correct order to load libraries . If you load bootstrap.min.js before jquery.min.js , you're wrong.

The right thing to do is:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><scriptsrc="js/bootstrap.min.js"></script>

If the upload is right, try:

<script>
      $(function(){
       $("#pdvcodigoean").keyup(function() {
         if (this.value.length === this.maxLength) {
          $('#pdvquantidade').focus();
         }
      });
      $("#pdvquantidade").focusin(function() {
       $.ajax({
         type: "POST",
         url: "pdv-produto-ajax.php",
         data: {
           codigoean: '7891111111111'
         },
         success: function (data) {
           alert(data.val);
          }
      });                     
    });
  });
</script>
    
13.01.2017 / 22:05