我在jquery的自动完成功能中加重了一些麻烦。 当我输入带有重音的字母时,我的结果就像“M& Aacute; THEUS”而不是“MÁTHEUS” 我试图改变utf8_encode解码然后我有“M?THEUS”
按照我的代码吼叫
retornar_cliente_processo.php
public class Verse {
public int SurahId { get; set; }
public int AyaId { get; set; }
public String Text { get; set; }
}
JS
<?php require_once("conexao/conexao.php"); ?>
<?php
$term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends
$qstring = "SELECT clienteNome as value,clienteId as id FROM cliente WHERE clienteNome LIKE '%".$term."%' LIMIT 10";
$consulta_tr = mysqli_query($conecta, $qstring);
if(!$consulta_tr) {
die("erro no banco1");
}
while ($row = mysqli_fetch_array($consulta_tr,MYSQL_ASSOC))//loop through the retrieved values
{
$row['value']=htmlentities(stripslashes(utf8_encode($row['value'])));
$row['id']=(int)$row['id'];
$row_set[] = $row;//build an array
}
echo json_encode($row_set);//format the array into json data
?>
HTML
$(document).ready(function() {
$('#clientes').autocomplete({
source: 'php/retornar_cliente_processo.php',
minLength: 1,
select: function(event, ui) {
$('#clienteId').val(ui.item.id);
$('.form-control').removeAttr("disabled");
$('#clientes').attr("disabled", "disabled");
$('#alteraNome').removeAttr("disabled");
},
}); }
答案 0 :(得分:1)
在这里,删除htmlentities(),这就是为什么你得到MÁTHEUS
而不是MÁTHEUS
的原因:
$row['value']=stripslashes(utf8_encode($row['value']));