[Users] Catching JSON

Smaran Harihar smaran.harihar at gmail.com
Fri Aug 17 22:12:01 CEST 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20120817/1690115c/attachment.htm 


More information about the Users mailing list