【发布时间】:2025-12-13 16:00:02
【问题描述】:
我需要在查询中传递葡萄牙语(BR)重音,这是我的 javascript 函数:
if (str.length == 0){
document.getElementById("pacientes_hint").innerHTML="";
return;
}
if(str.length > 2){
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById("pacientes_hint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","pacientes/busca/"+str, true);
xmlhttp.send();
}
我尝试了 escape(str) 和 encodeURI 都没有成功,谢谢
@编辑:
这是php函数
function busca(){
$q = utf8_decode(urldecode($this->uri->segment(3)));
echo $q;
$q = str_replace("%20", " ", $q);
$query = $this->model_pacientes->pegarLike($q);
foreach($query as $k){
echo "<div id='resultados_hint'>" . "<a href='#' onclick='clicar(this.firstChild.data);'>" .$k['Prinom']. "</a></div>";
}
}
【问题讨论】:
标签: javascript url utf-8