I've read that I can enable JSONP by setting ENABLE_JSONP in web.xml:


And I've read you can set outputFormat=json&format_options=callback:myCallback but I only get json back. Is this functionality broken/reverted? I'm on Windows 8.1.

  • Where's your wfs, we can test it. I have it working in GeoServer 2.4, so it must be somethign to do with your config. Did you restart Tomcat after changing the setting?
    – Alex Leith
    Mar 5, 2014 at 4:57

3 Answers 3


I got it to work using Geoserver 2.3 and Leaflet with WFS 1.0.0 here.

When I changed to version 1.1.0 and 2.0.0 it returned the same json object as 1.0.0 but neither rendered on the map. Not sure why and it's a bit beyond me.

Here's what I'm using:

var rootUrl = 'http://tomcat.capecodgis.com/geoserver/capecodgis/ows';

var defaultParameters = {
    service: 'WFS',
    version: '1.0.0',
    request: 'GetFeature',
    typeName: 'capecodgis:monitor_station',
    maxFeatures: 200,
    outputFormat: 'text/javascript',
    format_options: 'callback: getJson'


var parameters = L.Util.extend(defaultParameters);

    url: rootUrl + L.Util.getParamString(parameters),
    dataType: 'jsonp',
    jsonpCallback: 'getJson',
    success: handleJson

function handleJson(data) {
    L.geoJson(data, {
        onEachFeature: onEachFeature,
        pointToLayer: function (feature, latlng) {
            return L.circleMarker(latlng, geojsonMarkerOptions);
            //return L.marker(latlng);

Hope this helps


According to this document outputFormat=json is only included for backward compatibility and you should use outputFormat=text/javascript for a JSONP response.

  • 1
    Tried that but got a similar error: Failed to find response for output format text/javascript
    – ca0v
    Nov 6, 2013 at 16:10
  • what version of geoserver and wfs are you using? What does the getCapabilities doc suggest are available outputs
    – Ian Turton
    Nov 6, 2013 at 16:12
  • GeoServer 2.4.1 and tried 2.0.0 and 1.1.0 with the same outcome:… Seems to be a known issue: jira.codehaus.org/browse/GEOS-5749
    – ca0v
    Nov 6, 2013 at 16:14
  • You can't give us a localhost URL. Pastebin the xml, or stick it somewhere.
    – Alex Leith
    Mar 5, 2014 at 4:58

The problem is that the success function is not called with the JSONP call. You need to change the AJAX call accordingly. You need to set jsonp:'format_options' on the AJAX call. The callback is then in the jsonpCallback parameter.

        type: 'GET',
        data: {
            service: 'WFS',
            version: '1.1.0',
            request: 'GetFeature',
            typename: 'osm:water_areas',
            srsname: 'EPSG:3857',
            outputFormat: 'text/javascript',
            bbox: extent.join(',') + ',EPSG:3857'
        dataType: 'jsonp',
  • Unfortunately, no. I'm having the same problem. Using that example works; but using my geoserver tells me it doesn't accept text/javascript, despite enabling it in web.xml
    – Auspex
    Jan 26, 2017 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.