problem with javascript inputs do not call the function?

0

I have a problem in my code, I needed to do a search field only that I came across a problem the input field ignores the javascript and jquery function and in the case of the inputs submit nor refresh the page my code is as follows: / p>

// part javascript:

<script src="https://code.jquery.com/jquery-1.10.2.js"></script></script><script>jQuery.noConflict();(function($){$('#bs-mrb').on('keyup',function(e){if(e.which==13){//if($('#bs-prod').val()!="") {
                var dato = $('#bs-mrb').val();
                var x = $('#str').val();
                var url = x+'_functions.php?action=buscaMrb';
//              alert("dato: "+dato+" x: "+x+" url: "+url);
                $.ajax({
                    type:'POST',
                    url:url,
                    data:'dato='+dato,
                    success: function(datos){
                        $('#agrega-registros').html(datos);
                        r1 = tooltip();
                    }
                });
                return false;
            }
//      }
    });
})(jQuery);
</script>

// part HTML:

<body onLoad="tooltip();">
<?php
$funcao = $_REQUEST["op"];

if (function_exists($funcao)) {
    call_user_func($funcao);
}

function saida() {
titulo("FA - saída","course.png")  ?>
    <section>
    <table border="0" align="center">
        <tr>
         <td>
           <input type="hidden" name="str" id="str" value="aqm"/>
         </td>
    <form name="frm_pesq" method="post" action="">
         <td width="300">

<input type="text" placeholder="ID / PartNumber / SN Item" name="pesq" size="25" id="bs-mrb">
            <input type="hidden" name="str" id="str" value="fa"/>
         </td>
    </form>
       </tr>
   </table>
</section>

<div class="registros" id="agrega-registros">
        <table class="table table-striped table-condensed table-hover nowrap">
            <thead class="head">

                <th nowrap width="10px">Status</th>
                <th nowrap width="50px">ID</th>
                <th nowrap width="160px">DataEntrada</th>
                <th nowrap width="120px">PartNumber</th>
                <th nowrap width="140px">SNItem</th>
                <th nowrap width="140px">Description</th>
                <th nowrap width="150px">Defect</th>
                <th nowrap width="150px">TransferOrder</th>
                <th nowrap width="10px">teste</th>
            </thead>
            <?php 
                    aqui vai a query select * from tabela; 
                    e trás as informações do banco.
                      após isso fecho a função saída();
             } ?>

             </table>
            </div>

In the input field id="bs-mrb" does not call any function already tried javascript and jquery does not work only recognized a alert(); putting inside the input for example:

<input type="text" value="pesquisar" id="bs-mrb" onkeypress="alert('teste');">

So it worked more if I put an alert on a function does not work can anybody help me in this.

Detail my query is working the problem is only in the call of the javascript function in the input and also already tried to make an onsubmit inside the form and it did not work and also this page I am calling inside of another page index.

with the code below:

// javascript that calls the page above.

<script>
function display_c(){
    setInterval('getInfo()',30000);
}
function getInfo(){
    var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("conteudo").innerHTML = xmlhttp.responseText;
        }
    };
    xmlhttp.open("GET", "MRB_Dados.php?op=<?php echo $op;?>", true);
    xmlhttp.send('conteudo');
}
</script>

// and the html part that gets the page above inside the content div.

<body onload="display_c(); getInfo('<?php echo $op ; ?>');">
<div id="header">
<div id="masthead_upper" class="masthead full fullwidth">
  <div class="container_20">
    <div class="grid_6" id="logo"> <a href="http://<?php echo $_SERVER['SERVER_NAME'] ?>/coffe/mrb.php?op=<?php echo $op;?>">Lenovo</a> </div>
    <div style="position:absolute;color:white;font-family:Arial;font-size:32px;top:15px; right:20px; text-align: right;">Controle</div>
    <div style="position:absolute;color:white;font-family:Arial;font-size:10px;top:48px; right:20px; text-align: right;">Developed by Engineering System</div>
    <div style="position:absolute;top:65px; left:10px; text-align: left;">
    <nav class="grid_20 cf" id="menus"> 
        <ul class="fullwidth" id="navigation"><br>
          <li class="first" id="laptops"><font color="#FFCC00" face="verdana" size="2"><b><?php echo strtoupper($_SESSION['usuario'])." - ".strtoupper($_SESSION['nome']);?></b></font>
            <?php if(!empty($_SESSION['usuario'])) { ?> 
                <font color="#FFCC00" face="verdana" size="2"><?php echo " - ".strtoupper($_SESSION['depto']);?>|&nbsp;&nbsp;<a style="color: #fff;" href="logout.php">[logout]</a>&nbsp;&nbsp;|&nbsp;&nbsp;<span id="countDown" style="color:white"></span></font>
            <?php } ?>  
          </li>
        </ul>
    </nav>      
    </div>
    </div>
</div>
</div>
<div id="container">
<!-- begin: Main Grid -->
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
    <td width="100%" align="left" valign="top" bgcolor="#FFFFFF" class="landingcontent"><br />
        <table width="100%" height="100%" border="1" cellpadding="4" cellspacing="0">
        <tr>
            <td class="columnR" width="87%" valign="top" align="left">
            <!-- inicio td -->
                <div id="conteudo"></div>
            <!-- fim td -->      

          </td>
        </tr>
        </table>
    </td>
</tr>
</table>
</div>
<!-- end: Main Grid -->
<!-- begin: Footer -->
<?php // include "footer.php"; ?>
</body>
</html> 
    
asked by anonymous 09.03.2016 / 14:02

1 answer

1

It ignores why you expect to press the enter key to search:

if(e.which == 13) {

}

See the example:

jQuery.noConflict();
(function($) {
		
    $('#bs-mrb').on('keyup',function(e){
        if(e.which == 13) {
//          if($('#bs-prod').val() != "") {
                var dato = $('#bs-mrb').val();
                var x = $('#str').val();
                var url = x+'_functions.php?action=buscaMrb';
//              alert("dato: "+dato+" x: "+x+" url: "+url);
          
          alert("Pesquisando...")
          
                $.ajax({
                    type:'POST',
                    url:url,
                    data:'dato='+dato,
                    success: function(datos){
                        alert('Retorno pesquisa: ' + datos)
                    },
                  error: function(error){
                   alert('Erro pesquisa: ' + error.statusText)
                  }
                });
                return false;
            }
//      }
    });
})(jQuery);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><tableborder="0" align="center">
        <tr>
         <td>
           <input type="hidden" name="str" id="str" value="aqm"/>
         </td>
    <form name="frm_pesq" method="post" action="">
         <td width="300">

<input type="text" placeholder="ID / PartNumber / SN Item" name="pesq" size="25" id="bs-mrb">
            <input type="hidden" name="str" id="str" value="fa"/>
         </td>
    </form>
       </tr>
   </table>
</section>

<div class="registros" id="agrega-registros">
        <table class="table table-striped table-condensed table-hover nowrap">
            <thead class="head">

                <th nowrap width="10px">Status</th>
                <th nowrap width="50px">ID</th>
                <th nowrap width="160px">DataEntrada</th>
                <th nowrap width="120px">PartNumber</th>
                <th nowrap width="140px">SNItem</th>
                <th nowrap width="140px">Description</th>
                <th nowrap width="150px">Defect</th>
                <th nowrap width="150px">TransferOrder</th>
                <th nowrap width="10px">teste</th>
            </thead>

             </table>
            </div>
    
09.03.2016 / 14:24