我需要在查询上传递葡萄牙语(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();
}
我尝试了逃避(str)和encodeURI但没有成功,谢谢
@EDIT:
这是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>";
}
}
答案 0 :(得分:0)
xmlhttp.open("GET","pacientes/busca/" + encodeURIComponent(str), true);