0
我需要通過一個查詢葡萄牙語(BR)加重,這是我的javascript函數:通加重(JavaScript的)(GET)
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>";
}
}
嘗試這樣做,有一個JavaScript錯誤,這回在控制檯上: HTTP://(...)/pai/index.php/pacientes/busca/%25E9 404(未找到) – 2012-02-08 00:10:15
它看起來像'str'不包含你期望它包含的內容。打開連接之前「alert(str)」是什麼意思? – 2012-02-08 00:13:57
PS:發佈php功能as well – 2012-02-08 00:14:09