0

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?

Trident Splash
  • 649
  • 2
  • 10
  • 25
  • duplicate of http://stackoverflow.com/questions/926137/why-dont-i-get-a-same-origin-policy-warning-when-using-the-google-maps-api/926215#926215 – Jonathan Fingland May 30 '09 at 06:04
  • so, from what I understood GoogleMaps uses the 'script tag hack' to load my external XML file. It inserts the script src with its proxy server which then loads my external KML and delivers to the client. Does it convert between XML and JSON? – Trident Splash May 30 '09 at 06:16
  • the script they include is just going to be the javascript object they need and their custom event will be fired. xml to json conversion can certainly be done on the client side (google 'xml to json javascript converter' ) – Jonathan Fingland May 30 '09 at 06:49

2 Answers2

1

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
  • 39,690
  • 13
  • 62
  • 88
1

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
  • 348
  • 1
  • 10