在php中使用ajax时请求的页面不在服务器上错误

在php中使用ajax时请求的页面不在服务器上错误,php,ajax,drop-down-menu,Php,Ajax,Drop Down Menu,我在php中使用ajax创建下拉列表。我想在第一个drop中加载第二个drop下行列表 我写了下面的代码,但它给出了请求的页面不在服务器上的错误 <table style="font-family:Tahoma; font-size:18px;"> <tr><td>Category code:</td> <td> <select name="catcod" onchange="ajaxFunction()" > <o

我在php中使用ajax创建下拉列表。我想在第一个drop中加载第二个drop下行列表

我写了下面的代码,但它给出了请求的页面不在服务器上的错误

<table style="font-family:Tahoma; font-size:18px;">
 <tr><td>Category code:</td>
<td>
<select name="catcod" onchange="ajaxFunction()" >
<option value="00" selected="selected">--Select--</option>
<?php
$i=0;
while($catcod=mysql_fetch_array($cq))
{

        print "<option value=\"".$catcod ['cat_code']."\">".$catcod ['cat_desc']."</option>";

}?> 
</select></td>
</tr>
<tr>
    <td id="ajaxdiv">
    </td>
    </tr>
    <tr><td>Item number:</td><td><input type="text" name="itemnum" id="itemnum">    </td></tr>
    <tr><td>Description of Item:</td><td><input type="text" name="desc" id="desc"></td></tr>
    <tr><td>Number of items:</td><td><input type="text"  name="nom" id="nom"></td></tr>
    <tr><td>Date of purchase:</td><td><input style="color:#888;" maxlength="6"type="text"  name="date" id="date" value="DDMMYY"></td></tr>
    <tr><td>Orginal cost:</td><td><input type="text"  name="orgcost" id="orgcost"></td></tr>
    <tr><td>Employee code:</td><td><input type="text" maxlength="6" name="emp" id="emp"></td></tr>
   <tr>
    <td colspan="1"><center><input type="submit" value="Update"></td>
   </tr>
   </table>
php页面如下所示

   function ajaxFunction(){
   var ajaxRequest; 

   try{

  ajaxRequest = new XMLHttpRequest();
  }catch (e){

  try{
  ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  }catch (e) {
  try{
     ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }catch (e){

     alert("Your browser broke!");
     return false;
  }
  }
  }
  ajaxRequest.onreadystatechange = function(){
  if(ajaxRequest.readyState == 4){
  var ajaxDisplay = document.getElementById('ajaxdiv');
  ajaxDisplay.innerHTML = ajaxRequest.responseText;
  }
  }
  var catcod = document.getElementById('catcod').value;

  ajaxRequest.open("GET", "ajax.php  ?catcod="+catcod, true);
  ajaxRequest.send(null); 
  }
 <body>
 <div class="window">
<div class="header">
<?php
include_once '../header.php';

?>
</div>
<?php
$catcode=$_GET['catcod'];
include_once '../includes/Configurations.php';
$link = mysql_connect($_dbConfig['dbServer'],$_dbConfig['dbUser'],$_dbConfig['dbPassword'])or die(mysql_error());
$db = mysql_select_db($_dbConfig['dbName'], $link) or die(mysql_error());
$catnum_query ="select cat_desc,cat_no from item_master where cat_code=$catcode";
$cat=mysql_query($catnum_query,$link);?>
<select name="catcnum">
<?php
while($catnum=mysql_fetch_array($cat))
{
print "<option value=\"".$catnum ['cat_no']."\">".$catnum ['cat_desc']."</option>"; 
}?>
</select>
    </div>
    </body>

在您的代码中,没有id属性用于选择标记,但您正在使用

   var catcod = document.getElementById('catcod').value;
首先为提供id选择标记为

  <select name="catcod" id="catcod" onchange="ajaxFunction()" >


ajaxRequest.open(“GET”,“ajax.php?catcod=“+catcod,true”)
在.php和?另外,在ajax.php中不需要body标记或div标记。最后是同一个文件夹中的文件,因为ajax请求正在将一个文件与其自身放在同一个文件夹中。。。。空间是真正的问题,感谢您提供的额外信息…:)
 ajaxRequest.open("GET", "ajax.php  ?catcod="+catcod, true); //find the gap
  ajaxRequest.open("GET", "ajax.php?catcod="+catcod, true);