Problems when bringing a record in a database and showing it with javascript in a pop

0

I am doing a search in a form and that for example the user adds an id and that this id is stored in a variable and performs the search in the database.

For showing the data in the JavaScript I have no problems. The problem is that as it is a pop-up in real time, I do not know how to send the data of input to the search.

I put the code:

// formulario
<form id="alerta2">
    <input type="text" id="tickeid" name="tickeid" placeholder="Buscar Tu ticket">
</form>
 // codigo javascript
 <script>   
  $("#alerta2").submit(function(){
    dialog.alert({
      title: "Busqueda Realizada:",
      message: "<?php echo $ticket_id; ?>",
        button: "Cerrar",
      animation: "fade",
      callback: function(value){
        console.log(value);
      }
    });
    return false;
  });

</script>
    
asked by Avancini1 08.07.2017 в 23:57
source

1 answer

0

I changed it and now I am sending with ajax but I can not get it to send the input and show me the pop up information. This would be my ajax code

<script type="text/javascript">
    function ejecutar(str){
    var xmlhttp;
   if(str==""){
   document.getElementById("txtHint").innertHTML="";
   return;
}

    if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
    }else {
    xmlhttp = new ActivexObject("Microsoft.XMLHTTP");
    }

 xmlhttp.onreadystatechange = function(){
    if(xmlhttp.readyState==4 && xmlhttp.status==200){
   document.getElementById("alerta").innerHTML=xmlhttp.responseText;
    }
 }

    xmlhttp.open("GET","db.php?ticket="+str,true);
    xmlhttp.send();
     }
</script>

my html code

<form id="alerta2" action="">
 <input type="text" id="tickets" onload="ejecutar(this.value)" placeholder="Buscar Tu ticket">
</form>

and this would be my pop up code

 <script>   
  $("#alerta2").submit(function(){
    dialog.alert({
      title: "Busqueda Realizada:",
      message: "<div id='alerta'></div>",
        button: "Cerrar",
      animation: "fade",
      callback: function(value){
        console.log(value);
      }
    });
    return false;
  });

</script>
    
answered by 09.07.2017 в 19:46