title: Requested page not on server error while using ajax in php
body: <p>i was stdying dropdown using ajax in php. i want to load the second drop downlist based in the first drop.</p>
  
  <p>i wrote the following code,but its giving the requested page not on server error</p>
  
  <pre><code>&lt;table style="font-family:Tahoma; font-size:18px;"&gt;
   &lt;tr&gt;&lt;td&gt;Category code:&lt;/td&gt;
  &lt;td&gt;
  &lt;select name="catcod" onchange="ajaxFunction()" &gt;
  &lt;option value="00" selected="selected"&gt;--Select--&lt;/option&gt;
  &lt;?php
  $i=0;
  while($catcod=mysql_fetch_array($cq))
  {
  
          print "&lt;option value=\"".$catcod ['cat_code']."\"&gt;".$catcod ['cat_desc']."&lt;/option&gt;";
  
  }?&gt; 
  &lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td id="ajaxdiv"&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Item number:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="itemnum" id="itemnum"&gt;    &lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Description of Item:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="desc" id="desc"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Number of items:&lt;/td&gt;&lt;td&gt;&lt;input type="text"  name="nom" id="nom"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Date of purchase:&lt;/td&gt;&lt;td&gt;&lt;input style="color:#888;" maxlength="6"type="text"  name="date" id="date" value="DDMMYY"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Orginal cost:&lt;/td&gt;&lt;td&gt;&lt;input type="text"  name="orgcost" id="orgcost"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;Employee code:&lt;/td&gt;&lt;td&gt;&lt;input type="text" maxlength="6" name="emp" id="emp"&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;tr&gt;
      &lt;td colspan="1"&gt;&lt;center&gt;&lt;input type="submit" value="Update"&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;/table&gt;
  </code></pre>
  
  <p>the ajax code is as follows</p>
  
  <pre><code>   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); 
    }
  </code></pre>
  
  <p>and the ajax.php page is as follows</p>
  
  <pre><code> &lt;body&gt;
   &lt;div class="window"&gt;
  &lt;div class="header"&gt;
  &lt;?php
  include_once '../header.php';
  
  ?&gt;
  &lt;/div&gt;
  &lt;?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);?&gt;
  &lt;select name="catcnum"&gt;
  &lt;?php
  while($catnum=mysql_fetch_array($cat))
  {
  print "&lt;option value=\"".$catnum ['cat_no']."\"&gt;".$catnum ['cat_desc']."&lt;/option&gt;"; 
  }?&gt;
  &lt;/select&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  </code></pre>