0
Colleagues.
I am using the UI autocomplete for an application, it works fine until the word has accents. The database is set to:
The code I’m using is:
<input type="text" class="form-control" id="txtBuscar" name="BuscarProduto" placeholder="Buscar Produto">
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Autocomplete -->
<script>
$( function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
$( "#txtBuscar" ).autocomplete({
source: function( request, response ) {
$.ajax( {
url: "buscar.php",
dataType: "json",
data: {
term: request.term
},
success: function( data ) {
response( data );
//response( data );
}
} );
},
minLength: 2,
select: function( event, ui ) {
log( "Selected: " + ui.item.value + " aka " + ui.item.id );
}
} );
} );
</script>
My PHP is that way:
...
$nomeProduto = $_GET["term"];
$sqlBuscar = mysqli_query($conexao,"SELECT * FROM produtos WHERE NomeProdutos LIKE '%".mysqli_real_escape_string($conexao,$nomeProduto)."%';");
$trazer = array();
while($mostrar = mysqli_fetch_array($sqlBuscar)){
$trazer[] = $mostrar["NomeProdutos"];
}
echo json_encode($trazer);
Bingo Deyvid. It worked. I didn’t mind this native function. Thank you.
– user24136