upload data from ajax to datalist

0

hello I want to bring a list from my database but I already bring it what happens is that it does not show me and I really do not know what to do and a little help I liked.

function filtro() {
  // var valor = document.getElementById("destinatario").value;
  var valor = 'ke';
  if (valor.length > 0) {
    $.ajax({
      type: "GET",
      dataType: 'text',
      url: "filtrodestinatario.htm",
      data: {
        'email': valor
      },
      success: function(response) {
        var z = JSON.parse(response);

        var opcion = "<option value='" + z[0][0] + "'>" + z[0][0] + "</option>";
        //var opcion="<label>"+z[0][0]+"</label>";

        var todo = opcion;
        alert(todo);
        $("#usu").append(todo);
      },
      error: function(jqXHR, textStatus, errorThrown) {
        alert('Error: ');
      }
    });
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<input type='text' placeholder='Ingrese Usuario' class='flexdatalist' 
data-min-length='1' multiple='' data-selection-required='1' list='languages' 
id="destinatario" name='destinatario' onkeypress="filtro()">

<datalist id='languages'>
 <!-- <option value="kevin">jose</option>-->
                                                 <div id="usu"></div> 
                                            </datalist>
    
asked by Kevin Castaño 14.06.2017 в 23:34
source

0 answers