2012-02-07 10 views
0

が、これは私の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:

これは

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

PHP関数です:

xmlhttp.open("GET","pacientes/busca/" + encodeURIComponent(str), true); 
+0

が、これは、コンソールに返され、これを試してみましたが、javascriptのエラーを得た: ます。http://(...)/pai/index.php/pacientes/busca/%25E9 404(見つかりません) –

+0

'str'には、あなたが期待するものが含まれていないようです。接続を開く前に 'alert(str)'と言っているのは何ですか? –

+0

PS:PHP関数を投稿しました –