下拉菜单值未显示在首页上

时间:2015-04-08 19:36:04

标签: php html ajax dropdownbox

如果我正在点击AJAX获取数据但是我在控制台中获得的响应数据但是数据未在前视图下拉列表中呈现,则会有一个xyz下拉列表。

这是我的html和php代码。我得到了它在前视图中没有显示的值:

<tr>
    <td class="style2"> District </td>
    <td><select name= "district" id="district_response" class="span6 chzn-select" >
            <option value="">Select District</option>

      </select></td>
  </tr>

PHP代码

<?php $con = mysqli_connect("hostname","username","password","DBname")    or die (mysql_error());


$sname = $_POST['state_select'];
 $sq = "SELECT distinct(bank_district)  FROM bank_all whereb ank_state  ='".$_POST['state_select']."' order BY bank_district ASC";

$result1 = mysqli_query($con,$sq) or die('Error'.mysqli_error());
$resul1="";
while($row=mysqli_fetch_assoc($result1)){$resul1.= "<option  value ='{$row["bank_district"]}' >{$row["bank_district"]}</option>";}echo $resul1;?>







function jsFunction(){
 var myselect = $('#state_response').val();
 jQuery.ajax({
    url: "districtajax.php",
    global: false,
    type: "POST",
    data: ({  
        state_select:myselect,

    }),
    dataType: "html",
    async: false,        
    success: function (msg) {
    console.log(msg);
    //return false;
        $('#district_response').html(msg);
    }
});
}


</script>

0 个答案:

没有答案