views:

86

answers:

4

I am not able to call a file: "fillDropDown.php". Why this code is not working?

function MakeRequest()
{
  var xmlHttp = getXMLHttp();
  try 
  {
    xmlHttp.onreadystatechange = function()
    {
     if (xmlHttp.readyState == 4) 
     {
      HandleResponse(xmlHttp.responseText);
     }
    }
    xmlHttp.open("GET", "filldropdown.php", true);
    xmlHttp.send(null);
  }
  catch(err)
  {
    alert(err);
  }
}

Edited: =======

I am using AJAX code as suggested in this link: http://www.switchonthecode.com/tutorials/simple-ajax-php-and-javascript

A: 

How about with this?

function MakeRequest() {
    var xmlhttp;
    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) {
          alert("Cool. It's work. :)");
     }
    }

    xmlhttp.open("GET", "filldropdown.php", true);
    xmlhttp.send(null);
}

Make sure, "filldropdown.php" should be in same root with the document which contain above script.

Ei Maung
Not working either.
RPK
Didn't get any response? Didn't pop up an alert? Then, the problem might be in your "filldropdown.php". Did you echo something in your "filldropdown.php"?
Ei Maung
It is in the same location.
RPK
Yes, I have added echo on the very top of the .php file.
RPK
A: 

Without more code there is little we can do, doesn't look too bad but something I just want to clarify is that you are calling the file filldropdown.php but in your description you call it fillDropDown.php... case is important.

Ambrosia
+1  A: 

Is fillDropDown.php the correct filename?

I just ask because you're calling filldropdown.php... Depending on your webserver and/or your operating system, file paths are case-sensitive!

Stefan Gehrig
Lol, just asked that exact same question :P
Ambrosia
The file name is correct.
RPK
so the file name in the filesystem is exactly (case-sensitive): 'filldropdown.php' and not 'fillDropDown.php'?
Ambrosia
yes. File name is in lowercase.
RPK
What happens if you call `filldropdown.php` directly from your browser?
Stefan Gehrig
lol... you have fallen for one of the classic blunders, the most well known being "never start a land war in asia". Case sensitivity of file names is important in unix land!this code will work on a windows server, but not a unix one..you have to pay close attention to the case that you use. not all file systems are case insensitive.
Bingy
easy enough to tes as well.. try typing the file name into the webbrowser that you are using... If you get a file not found error with filldropdown.php but get success with fillDropDown.php, you will have located your error.
Bingy
A: 

I found that filldropdown.php script had errors. I fixed it and it is now running.

RPK