[OpenLayers-Users] Catching JSON

Phil Scadden p.scadden at gns.cri.nz
Sun Aug 19 15:08:23 PDT 2012


> I am using bottle to respond to the lat n long which has been sent. 
> Since I am not using CGI, using the cgi proxy is not helping. Also I 
> did try using cgi proxy but it made no difference.
Proxy is absolutely the way to get around cross-origin conflicts. Ajax 
uses XHR which necessarily has much tougher cross-origin policies.
The way this works is to have a proxy page INSIDE YOUR APPLICATION - ie 
in the same directory as your page or in a subdirectory below it.(so it 
is absolutely NOT a cross origin). The proxy page is code that needs to 
do this:
1/ check that the passed URL is reasonable for the application to call. 
If you dont do this, then you are creating an open proxy that can be 
used by spammers, anonymomizers, etc.
2/ Open an http connection to the passed page
3/ pipe the page content as output.

If you are returning json though, you can could instead look at using 
the openlayers script protocol. It depends on wrapping the returned json 
in a function call. (JSONP method if you want to read up on it).

However, I would say getting a working proxy up will save you a lot of 
grief.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list