I have a table that when I add some text that contains an accent adds all the other texts of that same condition. already tried several ways to use UTF-8 that I found on the net but none worked and I noticed in console.log () the following error only if you have any item in the table with an accent: "Uncaught SyntaxError: Unexpected end of input" and if it clears something else from the table (where it does not contain any words with an accent) I have return normally.
return_data.php
<?php
if ( isset($_POST['date']) ) {
$date = $_POST['date'];
}
$id_dentista = $_POST['id_dentista'];
$conecta = mysqli_connect("localhost","root","","odonto");
mysql_query("SET NAMES 'utf8';");
$selecao = "SELECT * from agenda WHERE dataAgenda = '{$date}' AND dentistaId = '{$id_dentista}' ORDER BY horaAgenda ";
$categorias = mysqli_query($conecta,$selecao);
$retorno = array();
while($linha = mysqli_fetch_object($categorias)) {
$retorno[] = $linha;
};
echo json_encode($retorno);
// fechar conecta
mysqli_close($conecta);
?>