views:

946

answers:

2

Google Maps's API object GGeoXML is able to access cross-domain XML files (usually KML or GeoRSS). It does not use XmlHttpRequest because it throws the "Access to restricted URI denied" exception (as it's supposed to). Also, it does not use Google's GXmlHttp wrapper because I've tried and it throws the same URI denied exception.

So, GGeoXML does not use XMLHttpRequest nor Google's GXMLHttp wrapper. How does GGeoXML access cross-domain XML files?

+1  A: 

If you do want to fetch cross-domain data via AJAX, the way to do it is using JSONP. It's essentially a JSON object wrapped in a function call. When the JSONP object returns to your server, the function is executed and it parses the JSON inside it back into a viable object.

JSONP was created specifically for the purpose of avoiding the cross-domain limitation of AJAX.

Gabriel Hurley
+1  A: 

There is a proxy on the backend that accesses this data 'cross-domain'. This avoids the cross-domain security feature in browsers.

JS call to "fetchData" calls a web service on the same domain the js is hosted. This backend proxy goes out 'cross domain' and accesses other information, parses it and returns it to the callback function of the 'fetchData' call.

Nael El Shawwa