2011-07-29 20 views
0

jQueryを使用してGoogle Places API 1を呼び出そうとしていますが、ドメイン間のセキュリティの問題が原因で障害が発生しているようです。私はこのリクエストをJSONPリクエストにして実行しようとしましたが、サーバーはJSONをまっすぐに返して、jQuery内で解析が失敗します。誰かがこれに対する解決策を見つけましたか?Google Places API

var requestUrl = "https://maps.googleapis.com/maps/api/place/search/json?location=" + 
        location.coords.latitude + "," + location.coords.longitude + "&radius=100&types=restaurant&sensor=false&key=<<api key here>>"; 

// Called with 
$.getJSON(requestUrl + "&callback=?", onLocateRestaurants); 
// or 
$.ajax({ 
    url: requestUrl, 
    type: 'GET', 
    dataType: 'jsonp', 
    crossDomain: true, 
    callback: 'test', 
    contentType: 'application/json', 
    success: onLocateRestaurants2, 
    error: defaultErrorHandler 
}); 
+0

が重複する可能性:詳細は、次の質問を(ケン・ブラウニングによってリンクされる)を参照してください? http://stackoverflow.com/questions/6104122/querying-google-places-api-using-jquery –

+0

Places APIはJSON-Pをサポートしていません。詳細については上記のKenにリンクされている質問を参照してください。 – monsur

+0

これらの回答を回答として入れることができますか?質問を閉じることができますか? –

答えて

関連する問題