[OpenLayers-Users] Http request?

Christopher Schmidt crschmidt at metacarta.com
Fri Jan 18 07:02:38 EST 2008


On Fri, Jan 18, 2008 at 11:38:40AM +0100, Andrea Maschio wrote:
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Please dont use HTML email. 

> Hello everybody, i'm new to this list. Please forgive my ignorance, but
> I didn't understand one thing: as far as i know, all modern browsers
> don't allow request generated by an AJAX request to other sites
> different from the web server from wich the client code was downloaded.

This is correct.

> I'm asking because downloading the OL distribution with examples and
> most of them are working from a page opened in browser from the file
> system.

But none of them use "AJAX" requests :)

The "X" in AJAX is for XML/XMLHttpRequest. XMLHttpRequest is not
neccesary to receive tiles -- instead, the proper URL is simply stuck
into an <img> tag, which (of course) can be loaded from other sites. (In
some circles, this would be called "hotlinking" -- especially in the
pink flashing ponies world of online social networking communities.) 

OpenLayers takes as a core tenet: "You can not talk to the server." This
means you can't use XMLHttpRequest to do anything that is crucial to
functionality unless there is no other way. All configuration, for
example, is not taken from the WMS GetCapabilities, but is instead taken
from local Javascript configuration -- duplicating information, but an
unfortunate consequence of the Same Origin Policy. 

The exceptions to this are requesting data from a remote server. So, WFS
requests -- wfs.html in the examples -- *do* request data from a remote
server. And you'll notice that it doesn't work on your local machine.

For the most part, OpenLayers is able to ignore the Same Origin Policy,
with some level of loss of support for using remote configuration
information. 

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list