Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a layer that can be configured to render as WFS or WMS. I want to apply the same sld styling that I have defined in Geoserver to make it consistent. But when I try to get the SLD text from geoserver I get an empty text. I use the following code to get the style from geoserver:

void init()
        url: "http://localhost:8080/geoserver/rest/styles/general.sld",
        success: complete

function complete(req) {
    var format = new OpenLayers.Format.SLD();

    sld = || req.responseText);


The req.responseXML and req.responseText is always empty. However, if I copy the sld file locally and then try to do a get I will successfully get the text from the sld file.

If I try to open the link on the web browser using the geoserver sld link then the browser attempts to download the file instead of viewing it. This could be the reason why the text returned is empty. If I try to open the sld link locally that I copied across from geoserver then the file would open up in the web browser.

Any one know how to solve this?

share|improve this question
you'll need a proxy - see numerous other questions – iant Apr 3 '13 at 13:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.