tags:

views:

209

answers:

3

I'm trying to write a javascript application that loads data from the openstreetmap API (http://wiki.openstreetmap.org/wiki/OSM_Protocol_Version_0.6), which is basically just a restful xml api. I'm trying to use jquery to access the XMl. however I get security errors. This is a cross site scripting blocking.

How can I access that XML? AFAIK OSM don't offer jsonp, so that doesn't work. Is there anyway?>

+1  A: 

Does this blog post help?

Dan Diplo
+2  A: 

The two ways to get round cross site scripting is to set up a server side proxy to call the url with your script calling your server side proxy. The other way is to call the data using the script tag which doesn't have restrictions on cross site calls.

Steve Mc
+1  A: 

The blog post linked by Dan shows you how to solve this problem, but here's the background:

The only way you can make a cross-domain Javascript call from a web page is via JSONP. If you aren't offered JSONP, then you will have to resort to using a Proxy script, as browsers purposefully prevent site scripts from making such calls.

Note that if you're writing a Firefox extension you are executing in a privileged space, and thus are able to make such cross-domain calls without restrictions.

toluju