我为选择字段设置了一个Chosen插件,以便用户能够从长列表中进行类型搜索.
虽然我正在为手机开发这款产品,虽然它在计算机上运行良好,但它在Apple和Android手机上都被禁用,弹出的默认用户界面用于选择输入.
我想在手机上使用这个插件.
我创建了一个jquery ajax请求,并尝试将一个变量传递给php来进行查询并将数据返回给实际的上下文.
处理ajax的实际上下文:
$.ajax({
type: 'post',
url: 'show.php',
data: {name: name},
dataType: 'json',
success: function(response) {
//here I'd like back the php query
}
Run Code Online (Sandbox Code Playgroud)
PHP:
$hostelName = $_POST['name'];
$sql = //here is the actual sql containing the $hostelname
$query = mysql_query($sql);
$obj = mysql_fetch_object($query);
$sum = $obj->sum;
$tour = $obj->tour;
echo json_encode(
array(
"sum" => $sum,
"tour" => $tour
)
);
Run Code Online (Sandbox Code Playgroud)