我有一个dropdown
用ajax填充动态的,
<select id="singer_list">
<option value='.$value.'>'.$option.'</option>
</select>
我的问题是:我无法获得
我正在使用dropdown
的值:$_POST
$singer_name=$_POST["singer_list"];
echo $singer_name;
但$singer_name
什么都不显示!如何选择dropdown
in 的值$_POST
?
我的ajax代码是:
<script type="text/javascript">
$(function(){
$("#genre_list").change(function(){
var genre_id=$("#genre_list").val();
$.ajax({
type:'POST',
url:'ajax_singer_list.php',
data:{'genre_id':genre_id},
success:(function(data){
$("#singer_list").append(data);
})
})
})
})
</script>
ajax_singer_list.php 处理程序:
<?php
include('../db_inc.php');
$genre_id =$_POST['genre_id'];
$result = $connection->query("SELECT singer_name,singerid from singers INNER JOIN genre_singer ON singers.singerid=genre_singer.f_singer_id where f_genre_id = '$genre_id'")or die($connection->error);
while($row = $result->fetch_object()){
$singer_name = $row->singer_name;
$singer_id = $row->singerid;
echo "<option value=$singer_id>$singer_name</option>";
}
$connection->close;
?>