문제

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

도움이 되었습니까?

해결책

Try running it in a page served by a web server instead of from a local file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top