Google の Suggest API からデータを取得し、自分のページに表示したい(おそらく追加機能を使用)。JSON の解析には自信がありますが、XML の解析には自信がありません。私が見る限り、Google は JSON でこの API を提供していません。
これどうやってするの?または、JSON でこの API にアクセスする方法を知っている人はいますか? 誰かがそれをしたら、それは素晴らしいでしょう!
API アドレスは次のとおりです: http://google.com/complete/search?q=google&output=toolbar
私の現在のコードは次のとおりです。
$.ajax({
type: "GET",
url: "http://google.com/complete/search?q=google&output=toolbar",
dataType: "xml",
crossDomain: true,
xhrFields: { withCredentials: true },
success: function(xml) {
$(xml).find('toplevel').each(function(){
var title = $(this).find('suggestion').text();
$('<b>'+title+'</b>').appendTo('#page-wrap');
});
}
});
そして、私が得ているエラーは次のとおりです。XMLHttpRequest cannot load http://google.com/complete/search?q=wixiy&output=toolbar. Origin is not allowed by Access-Control-Allow-Origin.