Get OSM-Data from Javascript

Hey everybody!

I want to write a JavaScript application which uses OSM data and I don’t want to double the bandwitdth usage for my website so I decided to use no proxy to circumvent “same origin”-policy which prohibits JavaScript’s XMLHttpRequest object to request data from another domain than the which the script is from to make XSS-attacks harder (which is only kind of good…) [0].
And so my question: What are my options to get OSM data?
I already tried several options:

  • directly querying (x) won’t work as my script is not allowed to read xml from *
  • indirectly querying (x) with yahoo pipes’s YQL won’t work as * has a robots.txt which doesn’t allow Yahoo’s service to access the site [1].
    I see no way to get the data without some server-side support. I see several options: a) OSM creates a JSONP like service [2], b) OSM employs a technique like the one described at [3] to allow to read osm data with IFrames (see below).
    b) should be easier:
  • create a webservice url that accepts a) some kind of query string and b) the desired domain name (/service?bbox=a,b,c,d&
  • return “a script” that looks like:

Are there any plans to support some kind of infrastructure to allow JavaScript to read OSM data?

I’m sure this is an issue that not only I’m having trouble with though I hardly found anything anywhere. E.g. Cartagen has similar problems (I think it must have) that’s why they have their own proxies. A solution which for several reasons I cannot deploy. As browser’s JavaScript engines become more powerful, JavaScript becomes a very good option to create cross-plattform applications and, in my humble opinion, OSM should support the development of that kind of applications!

Thank you for any input!