tags:

views:

268

answers:

1

I am trying AJAX for the first time on my localhost. I am using IIS and PHP with MySQL. This error is generated: "A HTTP Error 404.3 - Not Found" when I try this javascript command: xmlhttp.send(null);

xmlhttp is a varable and is used to retrieve the GetXmlHttpObject

+1  A: 

Just in-case something inside your xmlhttp object creation is not setup correctly or you have not waited for the correct status, have you looked at some simple xamples like from XUL.fr or W3 Shools or Your HTML Source?

Below is a simple example. Notice the inline function for the onreadystatechange callback and the check on readystate and status. I believe your issue may reside in you note doing these checks, but without your code I could be wrong.

<html>
<head>
<script>
function submitForm()
{ 
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }

    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                  document.ajax.dyn="Received:"  + xhr.responseText; 
              else 
                 document.ajax.dyn="Error code " + xhr.status;
         }
    }; 

   xhr.open(GET, "data.txt",  true); 
   xhr.send(null); 
} 
</script>
</head>

<body>
    <FORM method="POST" name="ajax" action="">                  
         <INPUT type="BUTTON" value="Submit"  ONCLICK="submitForm()">
         <INPUT type="text" name="dyn"  value=""> 
    </FORM>
 </body>
 </html>
Wayne