开发者

AJAX code not able to call a .php file

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

function MakeRequest()
{
  var xmlHttp = getXMLHttp();
  try 
  {
    xmlHttp.onreadystatechange = functio开发者_如何转开发n()
    {
        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


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!


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜