[Geoserver-users] GeoServer get GeoJSON issue

Greetings,

I am using GeoServer version 2.2.5, and what I try to do is making a AJAX call to get the json string from the output GeoJSON url, for example:

http://localhost:8080/geoserver/sf/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sf:archsites&maxFeatures=50&outputFormat=json

the javascript I used is like this:

var processJSON = function (data) {
console.log(data);
};
function init() {
//geojson url
var url = “http://localhost:8080/geoserver/sf/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sf:archsites&maxFeatures=50&outputFormat=json&&format_options=callback:processJSON”;

//execuate ajax request to get data
$.ajax({
url: url,
dataType: ‘jsonp’,
jsonp: ‘processJSON’
});

}

I am pretty sure that this method works, because I can get the json object from the url which is from GeoServer version 2.2.4. But it just doesn’t work for GeoServer 2.2.5 and later. I read somewhere that says “JSONP support has been disabled by default since it is perceived as a security issue.” But I have no idea how to make it work.

Can anyone give me some suggestion on this?

Thank you very much

On Tue, Jul 30, 2013 at 8:29 PM, Hongda Li <lhddragon87@anonymised.com> wrote:

Greetings,

I am using GeoServer version 2.2.5, and what I try to do is making a AJAX
call to get the json string from the output GeoJSON url, for example:

http://localhost:8080/geoserver/sf/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sf:archsites&maxFeatures=50&outputFormat=json

the javascript I used is like this:

        var processJSON = function (data) {
            console.log(data);
        };
        function init() {
            //geojson url
            var url = "
http://localhost:8080/geoserver/sf/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sf:archsites&maxFeatures=50&outputFormat=json&&format_options=callback:processJSON
";

            //execuate ajax request to get data
            $.ajax({
                url: url,
                dataType: 'jsonp',
                jsonp: 'processJSON'
            });

        }

I am pretty sure that this method works, because I can get the json object
from the url which is from GeoServer version 2.2.4. But it just doesn't
work for GeoServer 2.2.5 and later. I read somewhere that says "JSONP
support has been disabled by default since it is perceived as a security
issue." But I have no idea how to make it work.

By reading the docs:
http://docs.geoserver.org/latest/en/user/services/wfs/outputformats.html
http://docs.geoserver.org/latest/en/user/services/wms/global.html#wms-global-variables

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------