使用ajax/php调用时选择选项标记不会更改?

使用ajax/php调用时选择选项标记不会更改?,php,ajax,jquery-mobile,Php,Ajax,Jquery Mobile,下面的代码试图通过进行Ajax调用来更改Select选项标记,该调用连接到服务器上的PHP并检索数据。但是,如果我要将响应文本设置为span标记,那么下面的代码可以正常工作,但它不适用于Select option标记 <?php $q = intval($_GET['q']); $con=mysqli_connect("localhost","rot","ro","abc","3306"); / if (mysqli_connect_errno()) { echo "Fai

下面的代码试图通过进行Ajax调用来更改Select选项标记,该调用连接到服务器上的PHP并检索数据。但是,如果我要将响应文本设置为span标记,那么下面的代码可以正常工作,但它不适用于Select option标记

<?php

$q = intval($_GET['q']);

$con=mysqli_connect("localhost","rot","ro","abc","3306");

/

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }


$result = mysqli_query($con,"SELECT DISTINCT(UniqueBusId) FROM cfv_busstopnames WHERE busnumber = ".$q." ");


if (!$result) {
    printf("Error: %s\n", mysqli_error($con));
    exit();
}


while($row = mysqli_fetch_array($result))
  {
   echo "<option>" . $row['UniqueBusId'] . "</option>" ;

  }

mysqli_close($con);


?>


函数showUser(str)
{
如果(str==“”)
{
document.getElementById(“txtHint”).innerHTML=“”;
返回;
} 
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById(“选择选择方向”).innerHTML=xmlhttp.responseText;
}
}
open(“GET”、“getdirection.php?q=“+str.value,true”);
xmlhttp.send();
}
方向
而不是

xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
       document.getElementById("select-choice-direction").innerHTML=xmlhttp.responseText;
    }
}
试一试

这会告诉jQuery Mobile刷新selectmenu小部件()


为什么要将其标记为jQuery?你是如何触发你的功能的?
xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
       document.getElementById("select-choice-direction").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
        $('#select-choice-direction').html(xmlhttp.responseText).selectmenu( "refresh");
     }
}