0
I took a code that when something is typed in the input, it loads the data without refresh on the page, only that I wanted to do it through button, thus avoiding bugs.
I’m not able to convert the code to run with button.
My code . js:
$("#busca").keyup(function(){
var campo = $("#busca").val();
$.post('processa.php', {campo: campo},function(data){
$("#result").html(data);
});
});
parses.php
$campo = $_POST['campo'];
$result = "SELECT * FROM usuario WHERE nome = '$campo'";
$resultado = mysqli_query($conn, $result);
if($resultado->num_rows != 0 ){
while($row = mysqli_fetch_assoc($resultado)){
echo $row('nome');
echo $row(senha);
echo $row(data_nasc);
} else {
"Nenhum usuário encontrado"
}
form:
<form action="processa.php" method="POST">
<input type="text" class="form-control" name="busca" placeholder="Nome">
<button id="executar" type="button" class="btn btn-warning"">Buscar</button>
</form>
Didn’t work :/
– Antônio Leite
What mistake happened? Maybe it’s not a problem with the method itself. You came to clear the cache after changing (Ctrl + F5), sometimes this can disturb.
– ThiagoYou