Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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
Javascript 使用jquery获取机场代码_Javascript_Jquery - Fatal编程技术网

Javascript 使用jquery获取机场代码

Javascript 使用jquery获取机场代码,javascript,jquery,Javascript,Jquery,当我使用jquery查询机场代码时,它在国家/地区运行良好,但我希望机场代码按城市名称显示。但这是行不通的。我是通过json实现的。 这是我的密码,请告诉我,我的密码出了什么问题 <script> function buildQuery(term) { return "select * from json where url = 'http://airportcode.riobard.com/search? fmt=JSON&q=" + encodeURI(

当我使用jquery查询机场代码时,它在国家/地区运行良好,但我希望机场代码按城市名称显示。但这是行不通的。我是通过json实现的。 这是我的密码,请告诉我,我的密码出了什么问题

  <script>
  function buildQuery(term) {
    return "select * from json where url = 'http://airportcode.riobard.com/search?  fmt=JSON&q=" + encodeURI(term) + "'";
   }

   function makeRequest(request, response) {
     $.ajax({
      url: 'http://query.yahooapis.com/v1/public/yql',
      data: {
        q: buildQuery(request.term),
        format: "json"
     },
     dataType: "jsonp",
       success: function(data) {
        var airports = [];
        if (data && data.query && data.query.results && data.query.results.json &&  data.query.results.json.json) {
            airports = data.query.results.json.json;
        }

        response($.map(airports, function(item) {
            return {
                label: item.code + (item.name ? ", " + item.name : "") ,
                value: item.code
            };
        }));
     },
      error: function () {
        response([]);
        }
     });
   }

  $(document).ready(function() {
    $("#airport").autocomplete({
       source: makeRequest,
      minLength: 2
    });
  });
</script>

<input id="airport" />


<!-- HTML Code is -->

你们有什么错误?实际上,当我们进入像英国伦敦这样的特定城市时,它会显示机场代码。它显示的结果是错误的