2012-11-09 4 views
-3

각하 문제가 있습니다. 나는 codeigniter에있는 맥 시스템에서 작동한다. 이 아약스 코드는 구글 크롬에서 작동하지만, 파이어 폭스에서는 작동하지 않는다. 내 파이어 폭스 속성은 모질라/5.0이다. (맥킨토시, 인텔 맥 OS X 10.6, en-US, rv : 1.9.0.19) 게코/2010031218 Firefox/3.0.19ajax는 파이어 폭스에서 작동하지 않습니다.

<script> 
function showUser(str) 
{ 
    if (str=="") 
    { 
     document.getElementById("txtHint").innerHTML=""; 
     return; 
    } 
    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) 
     { 
      // alert(xmlhttp.responseText); 
      document.location.reload(true); 

      document.getElementById("txtHint").innerHTML=xmlhttp.responseText; 
     } 
    } 
    xmlhttp.open("POST","http://localhost/first_project/index.php/admin/selectUser/blank?q=" + str,true); 
    xmlhttp.send(); 
} 
</script> 

해결 방법을 알려주세요. 사전에 감사합니다.

+0

콘솔에 오류 메시지가 무엇인가에 무슨 일이 일어나고 있는지 볼 수있는 기능? – doniyor

+4

Firefox 3.0.19? Firefox ** 16 **에 대한 업데이트를 고려하셨습니까? :) – fresskoma

+0

여기 jquery에서 더 쉬운 아약스를 사용하는 방법을보세요 http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/ – doniyor

답변

4

이 아무 의미

 document.location.reload(true); <-- reload the document 

     document.getElementById("txtHint").innerHTML=xmlhttp.responseText; <--set text 

문서를 다시로드 할 때, 페이지의 텍스트를 설정하는 이유가에게하지 않습니다. 페이지가 종료되었습니다. 페이지를 다시로드하는 중 Ajax 요청을하는 이유는 무엇입니까? 정상적인 양식 제출을 사용하면됩니다.

변경

xmlhttp.onreadystatechange = function() { 
    if (xmlhttp.readyState==4) { 
     if (xmlhttp.status==200) { 
      // alert(xmlhttp.responseText); 
      document.location.reload(true); 
      //document.getElementById("txtHint").innerHTML=xmlhttp.responseText; 
     } else { 
      //console.error(xmlhttp.status + "\t" + xmlhttp.statusText); 
      alert(xmlhttp.status + "\t" + xmlhttp.statusText); 
     } 
    } 
}; 
+0

jQuery가 없으므로 귀하의 답변이 아프다 :) –

관련 문제