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",
              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);
                resp.code = OpenLayers.Protocol.Response.SUCCESS;
              } else
                // failure
                resp.code = OpenLayers.Protocol.Response.FAILURE;
              options.callback.call(options.scope, resp);



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

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.