[OpenLayers-Users] Catching JSON
Stephen Woodbridge
woodbri at swoodbridge.com
Mon Aug 20 09:54:05 PDT 2012
The domain and port must match the domain and port of the original page
that is making the ajax request.
On 8/20/2012 12:19 PM, Smaran Harihar wrote:
> Hi Phil,
>
> Thanks again for your guidance. I am bit confused when you said,
>
> have a proxy page INSIDE YOUR APPLICATION - ie
> in the same directory as your page or in a subdirectory below it.
>
> Did u mean that I should have my py script to which I making the AJAX
> request in the same dir? Then I already have. Only issue is that, the
> script is running on port 9000
> (http://128.196.142.94:9000/info?lat=53.33935546875&lon=-121.99951171875).
> So the domain is same but the ports are different.
>
> check that the passed URL is reasonable for the application to call
>
> I was able to call py script url (wget
> "http://128.196.142.94:9000/info?lat=53.33935546875&lon=-121.99951171875" -o
> test.1.log -O test.1), u can run this on terminal and it should fetch
> you the JSON.
>
> So, after this, how should I complete the other two parts?
>
> 2/ Open an http connection to the passed page
> 3/ pipe the page content as output.
>
> Thanks & Regrads,
> Smaran
>
> On Sun, Aug 19, 2012 at 3:08 PM, Phil Scadden <p.scadden at gns.cri.nz
> <mailto:p.scadden at gns.cri.nz>> wrote:
>
>
> > 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.
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org <mailto:Users at lists.osgeo.org>
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
More information about the Users
mailing list