سؤال

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