用于选择框的javascript函数不工作

用于选择框的javascript函数不工作,javascript,php,jquery,mysql,Javascript,Php,Jquery,Mysql,亲爱的,我是一个新的bie 该场景是基于以下第一个选择框的选择填充一个选择框“我的代码” 这部分代码填充了mysql中的第一个选择框,当我从选择框中选择一个值时,不会触发jquery函数,第二个选择框不会发生任何事情 <?php require_once("db_connect.php");?> <?php require_once("functions.php");?> <script type="text/javascript" src="jquery-1.10

亲爱的,我是一个新的bie

该场景是基于以下第一个选择框的选择填充一个选择框“我的代码”

这部分代码填充了mysql中的第一个选择框,当我从选择框中选择一个值时,不会触发jquery函数,第二个选择框不会发生任何事情

<?php require_once("db_connect.php");?>
<?php require_once("functions.php");?>
<script type="text/javascript" src="jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".brands").change(function()
     {
    var id=$(this).val();
   var dataString = 'id='+ id;

 $.ajax
 ({
 type: "POST",
 url: "array_types.php",
 data: dataString,
 cache: false,
 success: function(html)
   {
       $(".type").html(html);
   }
 });

 });

  });
 </script>
 <?php
 echo "Country :
<select name=\"brands\" class=\"brands\">";
    $brand_set=get_brands();
 while($brand=mysqli_fetch_assoc($brand_set)){
    echo "<option value=".$brand['brand_id'].">".$brand['brand_name']."</option>";
 }
echo "</select> <br/><br/>
    City :
<select name=\"type\" class=\"type\">
<option selected=\"selected\">--Select Type--</option>
</select>";
       ?>

$(文档).ready(函数(){
$(“.brands”).change(函数()
{
var id=$(this.val();
var dataString='id='+id;
$.ajax
({
类型:“POST”,
url:“array_types.php”,
数据:dataString,
cache:false,
成功:函数(html)
{
$(“.type”).html(html);
}
});
});
});
这是我的array_types.php

     <?php require_once("db_connect.php");?>
     <?php require_once("functions.php");?>
     <?php

     if($_POST['id'])
      {
      $id=$_POST['id'];
     $type_set=get_type_details($id);
while($type=mysqli_fetch_assoc($type_set)){
echo "<option value=".$type['prodtype_id'].">".$type['prod_type']."</option>";
}
     }?>

php基本上是从mysql数据库中删除记录 请告诉我为什么第二个选择框没有被填满

问候

柯达

明白了!
在第8行上,var dataString='id='+id;我必须传递brand_id而不是id

将文件jquery-1.10.2.js放在编码文件所在的同一目录中,然后在同一目录中尝试它。当ajax响应发出警报
html
时,您会得到什么?只需console.log(html)查看您得到了什么--选择类型——仅此而已