Monday, 20 March 2017

Enabling CORS in GeoServer 2.8.2 or how to use JSONP in GeoServer?


I want to identify number of layers in to workspace in GeoServer for that I am using below REST API:


http://admin:geoserver@localhost:8080/geoserver/rest/workspaces/gisc/featuretypes.json?callback=?


My application is running on IIS so I am using JSONP. I have enabled JSONP in GeoServer but I can not get output, always getting error "**Uncaught SyntaxError: Unexpected token :"


I tried:


var url  = "http://admin:geoserver@localhost:8080/geoserver/rest/workspaces/gisc/featuretypes.json?callback=?";

$.ajax({
type: 'GET',
url: url,

async: false,
jsonpCallback: 'parseResponse',
contentType: "application/json",
dataType: 'jsonp',
success: function(data)
{
console.log(data);
},
error: function (e)
{

console.log(e);
}
});

I have also tried another combination but it won't work I am always getting same error.


I have also tried to enable CORS in Jetty using "org\mortbay\servlets\CrossOriginFilter.class" it works with WMS and WFS but won't work with featuretypes.json.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...