Dojo Request from WMS 1.1.1 GetFeatureInfo

113 views Asked by At

I am trying to get response from GetFeatureInfo of sample WMS. But getting "Unable to load http://ogi.state.ok.us/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-104.5005,32.7501,-94.01,37.20&WIDTH=800&HEIGHT=300&LAYERS=ogi:okcounties&QUERY_LAYERS=ogi:okcounties&STYLES=&X=550&Y=105& status: 0"

var httpurl = "http://ogi.state.ok.us/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-104.5005,32.7501,-94.01,37.20&WIDTH=800&HEIGHT=300&LAYERS=ogi:okcounties&QUERY_LAYERS=ogi:okcounties&STYLES=&X=550&Y=105&";              
try {
              require(["dojo/request"], function (request) {
                  var promise = request(httpurl);

                  promise.response.then(
                      function (response) {
                          var kk = response;
                      },
                      function (error) {
                          var kk = error;
                      }
                  );
              });
          } catch (ex) {
              alert(ex.message);
          }
1

There are 1 answers

0
GavinR On

I see a couple potential issues:

  1. Based on the request documentation, I think you should call .then() directly on your promise. Lke this:

    promise.then(...);

  2. on this line: var kk = data; ... you're using the variable data but you should be using response.

  3. You may be getting a CORS issue - is your code running on the same domain as that URL? If not, and the website owner does not want to enable CORS for your domain, you may need to run a CORS proxy (google it)