0
In a field Blur event, I give a select in my bank and bring a value and fill in my html. My question is how I get more than one result or a specific result on the ajax date.
The code below works, but it only brings messaging if the customer is registered and separated if he is not registered. But beyond that, I want to fill out the combos with his data, vehicle color, model, brand automatically too.
I tried with Session, but in html it only appears if I leave and go back to page.
//fill the customer type after the card is typed - Input screen
$("#txtplaca").blur(function() {
var url = 'consulta_tip_cli.php';
var txtplaca = $("#txtplaca").val();
$.ajax ({
url: url,
data: {'txtplaca': txtplaca},
method: 'POST',
success: function(data) {
var msg = data;
$("#tipo").val(msg);
},
beforeSend: function(){
$("#loader").css({display:"block"});
},
complete: function(){
$("#loader").css({display:"none"});
}
});
});
my php:
<?php
include_once('status_logado.php');
require_once('db.class.php');
$placa = $_POST['txtplaca'];
$sql = "SELECT idmensalista FROM `tbl_mensalista` join tbl_veiculo on IDMENSALISTA = id_mensalista ";
$sql = $sql."where vei_placa = '$placa'";
$objDb = new db();
$link = $objDb->conecta_mysql();
$resultado = mysqli_query($link,$sql);
$rows = mysqli_num_rows($resultado);
if($rows) {
echo "Mensalista";
} else {
echo "Avulso";
}
?>
I made a modification : $Rows = mysqli_fetch_assoc($result) - To have an array. When I print the date, it shows me the array. When I print the date.idmensalista, for example, it comes: Undefined. In its original form, it didn’t work :(
– João Paulo Silva
But
data["idmensalista"]
worked?– Wees Smith
It did not work, I will test other ways. It comes Undefined too
– João Paulo Silva
@Joãopaulosilva Put one
console.log(data)
in thecomplete
and post here what is showing.– Sam