Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui 如何使用jquery自动完成从json文件获取值_Jquery Ui - Fatal编程技术网

Jquery ui 如何使用jquery自动完成从json文件获取值

Jquery ui 如何使用jquery自动完成从json文件获取值,jquery-ui,Jquery Ui,这是我的jquery代码 $('.typeahead',此)。自动完成({ 我的Json文件是 [ { “代码”:“9BP3”, “名称”:“9Bp No3” }, { “代码”:“AA”, “名称”:“共济失调” },{ “代码”:“BILA”, “名称”:“贝斯拉纳” }, { “代码”:《图片报》, “名称”:“比尔迪” },{ “代码”:“HRI”, “名称”:“Hardoi” }, { “代码”:“人力资源管理”, “姓名”:“Hadmadiya” } ] 当我键入任意三个字母时,它将

这是我的jquery代码

$('.typeahead',此)。自动完成({

我的Json文件是 [ { “代码”:“9BP3”, “名称”:“9Bp No3” }, { “代码”:“AA”, “名称”:“共济失调” },{ “代码”:“BILA”, “名称”:“贝斯拉纳” }, { “代码”:《图片报》, “名称”:“比尔迪” },{ “代码”:“HRI”, “名称”:“Hardoi” }, { “代码”:“人力资源管理”, “姓名”:“Hadmadiya” } ]


当我键入任意三个字母时,它将返回整个json文件值

q:request.term这是从stations.json中筛选返回值的字符串。您必须将类似这样的变量传递给筛选结果。stations.json必须是动态生成的文件,如带有json头的php。q是$\u GET参数,必须进行解析。请尝试如下更改代码:

$.ajax({
  url: "includes/stations.json",
  dataType: "json",
  data: {
    q: request.term // here is the string for filter returned values from stations.json. You must pass variable like this to filter results. stations.json must be dynamically generated file like php with json header. q is $_GET parameter and must be parsed.
  },
  success: function(data) {
    response(
        $.map(data, function(item, i) {
            return {
                label: item.name,
                value: item.code
            }
        })
    );
}
});
},
minLength: 3,
$.ajax({
  url: "includes/stations.json",
  dataType: "json",
  data: {
    q: request.term // here is the string for filter returned values from stations.json. You must pass variable like this to filter results. stations.json must be dynamically generated file like php with json header. q is $_GET parameter and must be parsed.
  },
  success: function(data) {
    response(
        $.map(data, function(item, i) {
            return {
                label: item.name,
                value: item.code
            }
        })
    );
}
});
},
minLength: 3,