jquery 自动完成功能在移动设备中无法正常工作

问题描述 投票:0回答:1

我的主页有四个自动完成输入框,在桌面/PC上都工作正常,但在移动默认浏览器和chrome移动中它不显示从服务器返回的结果..

这是我的页面网址:http://must4you.com/beta/

我的脚本:

$( "#market" ).autocomplete({
  source:function(request, response) {
     // alert("hello");
    $.ajax({
        url: "http://must4you.com/beta/index.php/Autocomplete/get_market_help",
        dataType: "json",
        data: {
            term : request.term,
            state : $("#states").val(),
            city:$("#cities").val(),
            area: $("#area").val(),
            pin:$("#pincode").val(),
        },
        success: function(data) {
          response(data);
        }
    });
  },
  minLength: 2,
});

在控制器中

public function get_market_help(){
    $text = $_REQUEST['term'];
    $data = $this->M_autocomplete->get_market_suggestion($text);
    $data_suggest = array();
    foreach($data as $row){
    $data_suggest[$row->location] = trim($row->location);
    }
   // print_r($data_suggest);
    //echo "TEST HELLO";
    //
    echo json_encode($data_suggest);
}

注意:其他自动完成功能具有相同的代码,但它们在电脑和移动设备上都运行良好

jquery json codeigniter jquery-ui autocomplete
1个回答
0
投票

确保您的 HTML 文档包含视口

meta
标签,以便在移动设备上正确缩放。在 HTML 文档的
<head>
部分添加以下元标记:

<meta name="viewport" content="width=device-width, initial-scale=1">
© www.soinside.com 2019 - 2024. All rights reserved.