PHP5中的Ajax - 使用其他下拉列表更新下拉列表

I'm trying to update drop down list with the other drop down list using Ajax. Somehow it is not working. I'm not sure which path is going wrong.

php file

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
    function AjaxFunction(cat_id)
    {
    var httpxml;
    try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
        try
                   {
                httpxml=new ActiveXObject("Msxml2.XMLHTTP");
                }
           catch (e)
                {
             try
            {
            httpxml=new ActiveXObject("Microsoft.XMLHTTP");
            }
             catch (e)
            {
            alert("Your browser does not support AJAX!");
            return false;
            }
          }
  }
function stateck() 
    {
    if(httpxml.readyState==4)
      {

var myarray=eval(httpxml.responseText);
for(j=document.testform.subcat.options.length-1;j>=0;j--)
{
document.testform.subcat.remove(j);
}


for (i=0;i<myarray.length;i++)
{
var optn = document.createElement("OPTION");
optn.text = myarray[i];
optn.value = myarray[i];
document.testform.subcat.options.add(optn);

} 
      }
    }
   var url="dd2.php";
url=url+"?cat_id="+cat_id;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
  }
</script>


<title>tresn</title>
</head>


<table width="1021" border="0" style="top:0;left:0; position:fixed">
  <tr>
    <td height="25"><form action='Test3.php?mula=0&amp;akhir=12' method="POST" class="dropdown_button" name="testform" id="form1">
      <strong> 
        Sort By:
        <select name="cat" onchange="AjaxFunction(this.value);" id="SortBy">
          <option value="0">(Short By)</option>
          <?php
$q=mysqli_query($db,"select * from db_prd_category ");
while($n=mysqli_fetch_array($q)){
echo "<option value=$n[Cat_Id]>$n[Name]</option>";
}
?>
        </select>
        <select name="subcat">
        </select>
        <input type="submit" class ="small button yellow" name="Filter" id="Filter" style="height:25px" value="Filter" />
        &nbsp; </strong>
    </form></td>
  </tr>
</table>`

Ajax file

<?php
$cat_id=$_GET['cat_id'];
require "config.php";

$q=mysqli_query($db,"Select * from db_prd_subcategory where Cat_Id='$cat_id' ORDER BY  SubCat_Id ASC");
echo mysqli_error();
$myarray=array();
$str="";

while($n=mysqli_fetch_array($q)){
$str=$str . "\"$nt[Name]\"".",";
}

$str=substr($str,0,(strLen($str)-1)); 
echo "new Array($str)";

?>