Exemplo ajax nao funciona!

2 respostas
brlima

Nao da nenhum erro? Ja tentou colocar uns alerts pra ver qual caminho tá seguindo???

Eu vi tb que pode ter outro objeto de criacao do request:

new ActiveXObject("Msxml2.XMLHTTP");

2 Respostas

I

Gente eu ja verifiquei todo o código , so que nao esta exibindo a mensagem que eu estou querendo , sendo que ele chama as funcoes nomais …

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
       
       var xmlHttp ;
       
       function createXMLHttpRequest(){
             
          if(window.ActiveXObject){
         
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
         
          } else 
         
              if(window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();      
              }
      }
       
     function startRequest(){
           
          createXMLHttpRequest();
          xmlHttp.onreadystatechange = handleStateChange;
          xmlHttp.open("GET","simpleResponse.xml",true);
          xmlHttp.send(null);
          
     }  
       
    function handleStateChange() {
          
         if (xmlHttp.readyState == 4) {              
                     
              if (xmlHttp.status == 200) {
       
                                     
                    alert(" O servidor foi chamado :" + xmlHttp.responseText );
                    

             }
         }
    }   
   </script>
</head>
<body>

<form action="#">
   <input type="button" value="Start basico assincrono" onclick="startRequest();"/>
</form>
</body>
</html>

Sera que nao esta carregando na parte dos estatos …?

I

Nao da erro nenhum nao !

Eu coloquei os alerts so que ele nao exibe o alert que eu coloco dentro
trecho do codigo . Ou seja é como se ele nao tivesse acessando .

if (xmlHttp.status == 200) {
       
                                     
                    alert(" O servidor foi chamado :" + xmlHttp.responseText );
                    

             }

O resto e exibe .

Criado 2 de agosto de 2006
Ultima resposta 2 de ago. de 2006
Respostas 2
Participantes 2