1

问题:

尝试使自动完成功能与 Amadeus Airport Autocomplete 一起使用,可在此处找到:

https://sandbox.amadeus.com/travel-innovation-sandbox/apis/get/airports/autocomplete

最小的例子:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>jQuery UI Autocomplete</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <style>
    #city {
      width: 25em;
    }
  </style>
  <script>
    $(function() {
      function log(message) {
        $("<div>").text(message).prependTo("#log");
        $("#log").scrollTop(0);
      }
      $("#city").autocomplete({
        source: function(request, response) {
          $.ajax({
            url: "http://api.sandbox.amadeus.com/v1.2/airports/autocomplete",
            dataType: "json",
            data: {
              apikey: "SECRET",
              term: request.term
            },
            success: function(data) {
              response(data);
            }
          });
        },
        minLength: 3,
        select: function(event, ui) {
          log(ui.item ?
            "Selected: " + ui.item.label :
            "Nothing selected, input was " + this.value);
        },
        open: function() {
          $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function() {
          $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        }
      });
    });
  </script>
</head>

<body>
  <div class="ui-widget">
    <label for="city">Your city: </label>
    <input id="city">
  </div>
  <div class="ui-widget" style="margin-top:2em; font-family:Arial">
    Result:
    <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
  </div>
</body>

</html>

期望的输出:

在您键入时获取列表中的机场列表。感谢有人能指出我错过了什么。

4

1 回答 1

1

原来答案很简单。Safari 9.0 似乎阻止了“不安全的内容”,我所要做的就是将 http:// 更改为 https:// 以使其正常工作。

于 2016-05-17T14:07:25.420 回答