[Users] Catching JSON

Christian Mayer mayer at terrestris.de
Thu Sep 20 20:15:01 CEST 2012


Hi Smaran,

the first possibility to get around the SOP ist the proxy-cgi-script of 
OpenLayers:

http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost

If you are using GeoExt 1.x there is another JavaScript file you can 
load which takes care that all AJAX-requests done with ExtJs/GeoExt are 
passed through the OpenLayers Proxy:

http://geoext.org/lib/overrides/override-ext-ajax.html

Best regards,
Chris

Am 17.08.2012 22:12, schrieb Smaran Harihar:
> Hi,
>
> I am returning a JSON to a GeoExt app and this is the code that is 
> collecting the return,
>
>     var control = new OpenLayers.Control.Click({
>                           trigger: function(evt) {
>                           var lonLat = evt.xy;
>                           if (popup) popup.close();
>                           var  request = Ext.Ajax.request({
>       url:"http://128.196.142.94:9000/info?lat="+ 
> panel.map.getLonLatFromViewPortPx(lonLat).lat +"&lon=" + 
> panel.map.getLonLatFromViewPortPx(lonLat).lon,
>                           disableCaching: false,
>                           success: function(response) {
>       var obj = Ext.decode(response.responseText);
>  console.log(obj);
>  console.dir(obj);
>  addToPopup(lonLat, response.responseText);
>       },
>   failure: function(response) {
>  console.log('server-side failure with status code ' + response.status);
>  addToPopup(lonLat, "Server side Failure");
>   }
>                                  //callback: myhandler
>                      });
>     }});
>
> I wish to obtain the returned JSON and then assign it to the popUp but 
> whenever I try to connect to the App it is returning the following error,
>
>     OPTIONS 
> http://128.196.142.94:9000/info?lat=55.44873046875&lon=-118.17626953125 405 
> (Method Not Allowed)
>     XMLHttpRequest cannot load 
> http://128.196.142.94:9000/info?lat=55.44873046875&lon=-118.17626953125. 
> Origin null is not allowed by Access-Control-Allow-Origin.
>     test.html:222server-side failure with status code 0
>
> If you simply pass the url 
> `http://128.196.142.94:9000/info?lat=55.44873046875&lon=-118.17626953125` 
> <http://128.196.142.94:9000/info?lat=55.44873046875&lon=-118.17626953125> you 
> will obtain the JSON but for some reason there is failure that keeps 
> occurring in the application.
>
> Is there CORS that can be used in the OpenLayers or GeoExt. I have 
> tried using ExtJS JSON-P but I am not sure what should I enter in the 
> 'callback' of,
>
> <script src="http://domainB.com/users?callback=someCallback 
> <http://domainb.com/users?callback=someCallback>"></script>
>
> Thanks,
> Smaran
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20120920/d7042c89/attachment.htm 


More information about the Users mailing list