Colleagues.
I'm using the autocomplete UI for an application, it works fine until the moment the word has accents. The bank is configured as:
ThecodeIamusingis:
<inputtype="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(){functionlog(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 looks like this:
...
$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);