[OpenLayers-Users] Catching JSON

Imran Rajjad rajjad at gmail.com
Fri Aug 17 23:36:15 PDT 2012


Hi Stephen.

did you try Openlayers`s request method?

http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Request-js.html

Same Origin Policy should allow JSON to come through! I think it would
be better to implement the request method a bit separately using the
events of the Click control.

regards,
Imran

On Fri, Aug 17, 2012 at 11:50 PM, Smaran Harihar
<smaran.harihar at gmail.com> wrote:
> Thanks for the reply Steve.
>
> 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.
>
>
> On Fri, Aug 17, 2012 at 11:45 AM, Stephen Woodbridge
> <woodbri at swoodbridge.com> wrote:
>>
>> Is you main page loading from http://128.196.142.94:9000/...
>> If not you are trying to make an Ajax request to a host that is not the
>> same as the page that you loaded. This is not allowed because of Same Origin
>> Policy. You can setup a proxy to work around this.
>>
>> -Steve W
>>
>>
>> On 8/17/2012 2:35 PM, Smaran Harihar wrote:
>>>
>>> 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%60>
>>>
>>> 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"></script>
>>>
>>>
>>> --
>>> Thanks & Regards
>>> Smaran Harihar
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> 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
>
>
>
>
> --
> Thanks & Regards
> Smaran Harihar
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
I.R


More information about the Users mailing list