Try running it in a page served by a web server instead of from a local file.
Can't obtain Google Search suggestion API
-
11-12-2021 - |
문제
Trying to use an xmlHTTPrequest to get search suggestions but I am having trouble getting access.
The link is: http://suggestqueries.google.com/complete/search?output=toolbar&hl=ja&q=keyword It loads fine when put into the address bar.
I have already written a code to get xml files from a Rakuten API which works. I tried using it with this URL instead but it fails to get any information.
This is the error in Chrome: XMLHttpRequest cannot load http://suggestqueries.google.com/complete/search?output=toolbar&hl=ja&q=keyword. Origin null is not allowed by Access-Control-Allow-Origin.
This is the xml part of the code used.
var getURL="http://suggestqueries.google.com/complete/search?output=toolbar&hl=ja&q=keyword";
xmlhttp.open("GET",getURL,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
What is needed to get this to work?
Thanks
해결책
제휴하지 않습니다 StackOverflow