59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
$(buscar_datos_p());
|
|
|
|
function buscar_datos_p(consulta){
|
|
$.ajax({
|
|
url: 'busqueda_p.php',
|
|
type: 'POST',
|
|
dataType: 'html',
|
|
data: {consulta: consulta},
|
|
})
|
|
.done(function (respuesta) {
|
|
$('#datos').html(respuesta);
|
|
})
|
|
|
|
.fail(function () {
|
|
console.log("error");
|
|
})
|
|
|
|
}
|
|
|
|
$(document).on('keyup','#caja_busqueda', function(){
|
|
var valor = $(this).val();
|
|
console.log(valor);
|
|
if (valor != "") {
|
|
buscar_datos_p(valor);
|
|
}else{
|
|
buscar_datos_p();
|
|
}
|
|
});
|
|
/*
|
|
//funcion global
|
|
var buscar = function(consulta){
|
|
$.ajax({
|
|
url: 'busqueda_p.php',
|
|
type: 'POST',
|
|
dataType: 'html',
|
|
data: {consulta: consulta, text:'asd'},
|
|
})
|
|
.done(function (respuesta) {
|
|
$('#datos').html(respuesta);
|
|
console.log(respuesta)
|
|
})
|
|
|
|
.fail(function () {
|
|
console.log("error");
|
|
})
|
|
}
|
|
buscar()
|
|
let input = document.getElementById('caja_busqueda')
|
|
|
|
input.addEventListener("keyup",function(){
|
|
if (input.value == ""){
|
|
buscar()
|
|
}else{
|
|
console.log("lleno")
|
|
|
|
buscar(input.value)
|
|
|
|
}
|
|
})*/ |