0

I am not able to call a file: "fillDropDown.php".

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

5
  • what's the error you're getting? Are you sure the path is correct (it must be relative to the html page calling the javascript)? Commented Nov 17, 2009 at 10:13
  • Does getXMLHttp() return the correct XHR object depending on the browser? Commented Nov 17, 2009 at 10:18
  • ..and/or pop open the javascript console of your browser and tell us if there's an error message there. Commented Nov 17, 2009 at 10:28
  • It is not displaying any error nor passing control to that file. Commented Nov 17, 2009 at 10:30
  • please post a link where we can see the whole html+javascript code in action. Commented Nov 17, 2009 at 11:31

4 Answers 4

1

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!

Sign up to request clarification or add additional context in comments.

5 Comments

Lol, just asked that exact same question :P
so the file name in the filesystem is exactly (case-sensitive): 'filldropdown.php' and not 'fillDropDown.php'?
What happens if you call filldropdown.php directly from your browser?
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.
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.
0

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.

2 Comments

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"?
Yes, I have added echo on the very top of the .php file.
0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.