I have a question and I have not been able to find a solution.
What happens is that I'm using a bar code in a input
, but this input
also has a function to look up real-time data (ajax) in the database, which I try to do when the bar code type and it's very fast, my search function does not skip.
I need something that detects the writing time, if it is very fast just write but if it is slow look.
Thank you very much greetings.
$(document).ready(
function() {
//al momento de escribir busca productos
$("#buscar").keyup(function() {
mostrarproductos();
});
}
function mostrarproductos() {
var buscartx = $('#buscar').val();
$.ajax({
url: BASE_URL + "vender/mostrarproductos",
type: "POST",
data: {
buscar: buscartx
},
success: function(respuesta) {
var registro = eval(respuesta);
var contar = 0;
var html;
for (var i = 0; i < registro.length; i++) {
html += "<tr>";
html += "<td id=" + registro[i]["codigo2"] + ">" + registro[i]["codigo2"] + "</td>";
html += "<td>" + registro[i]["nombre"] + "</td>";
html += "<td>" + registro[i]["stock"] + "</td>";
html += "<td>" + registro[i]["precio"] + "</td>";
html += "</tr>";
contar += 1;
};;
if (contar > 0) {
$("#tbody-01").html(html);
// $("#resultx").text("Resultado encontrados: " + contar);
} else {
$("#table-01 tbody tr").remove();
// $("#resultx").text("Resultado encontrados: 0");
}
}
});
}
<input id="buscar" name="buscar"
class="form-control text-uppercase mx-1 texbox_min"
type="text" placeholder="Buscar">