質問

使っていたgeonames.org を自動補完の都市国家だという見解を示したためあまりにも遅いです。私のコードと、以下のようになりますが、やは作業(約10秒のオートコンプリート結果)

古い(コード: http://jsbin.com/umewo3/2/edit

  $(function() {
    $( "#sf_city" ).autocomplete({
      source: function( request, response ) {
        $.ajax({
          url: "http://ws.geonames.org/searchJSON",
          dataType: "jsonp",
          data: {
            featureClass: "P",
            style: "full",
            maxRows: 10,
            country: 'US',
            name_startsWith: request.term
          },
          success: function( data ) {
            response( $.map( data.geonames, function( item ) {
              return {
                value: item.name + (item.adminName1 ? ", " + item.adminCode1 : "")
              }
            }));
          }
        });
      },
      minLength: 2
    });
  });

現在、そのまま使用YQLとして提供されているかに迅速に応じます。問題は、私がいなかったのでしょうかいかに適切な地図をします。きを送りたいと思い形の要請に対応バックをしたいが何とかな対応に対応す。

新壊れたコードはこちら http://jsbin.com/aqoke3/2/edit

$(function() {
    $( "#sf_city" ).autocomplete({
      source: function( request, response ) {
        $.ajax({
          url: "http://query.yahooapis.com/v1/public/yql",
          dataType: "json",
          data: {
            q: 'select name,admin1.code from geo.places where text="' + request.term + '*" and country.code="US" limit 10 | sort(field="popRank", descending="true")',
            format: 'json',
            callback: 'cbfunc'
          },
          success: function( data ) {
            response( $.map( data.query.results.place, function( item ) {
              return {
                value: item.name
              }
            }));
          }
        });
      },
      minLength: 2
    });
  });
役に立ちましたか?

解決

この問題です。私は取り扱います。から受けることになってしまいを削除しPからのjsonp dataType.

すべてのもの: http://jsbin.com/aqoke3/4/edit

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top