Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a service that sometimes takes awhile to provide a response. I'm trying to capture the initial call to the service so that I can put a "Loading...please wait" message until I get the response. I can't seem to find a way to get at the ajax portion of the HTTP Protocol request. Essentially, I'm looking for something analogous to jquery's ajaxstart. Has anyone done this or know how to do this? I looked into Openlayers event listeners, but couldn't find much there that helped.

var myVectorLayer = new OpenLayers.Layer.Vector("My Vector Layer", {
      projection: "EPSG:4326",
      strategies: [new OpenLayers.Strategy.BBOX({resFactor: 1})],
      protocol: new OpenLayers.Protocol.HTTP({
          url: "./resource/getData.php",
          params:{                
              zoom: me.map.getZoom(),
              density: 1
          },
          format: new OpenLayers.Format.JSON(),
       // Over-riding handle Response to get at feature attributes
          handleResponse : function(resp, options)
          {
            var request = resp.priv;                
            if (options.callback)
            {
              if (request.status >= 200 && request.status < 300)
              {
                // success
                if (resp.requestType != "delete") {
                  resp.features = this.parseFeatures(request);
                }
                console.log('success');
                resp.code = OpenLayers.Protocol.Response.SUCCESS;
              } else
              {
                // failure
                resp.code = OpenLayers.Protocol.Response.FAILURE;
                console.log('failed');
              }
              options.callback.call(options.scope, resp);
            }

            me.updateData(resp.features);

          }
        }), 
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Try to use loadstart and loadend events of OpenLayers.Layer.

share|improve this answer
add comment

Your Answer

 
discard

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

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