[OpenLayers-Users] I'm stuck trying to decorate OpenLayers.Request.issue

Umberto Nicoletti umberto.nicoletti at gmail.com
Sat Feb 2 00:50:43 PST 2013


I would use an event listener instead:

start the timer on complete event

stop and log  it on success or failure

hth,
Umberto

On Saturday, February 2, 2013, Stephen Woodbridge wrote:

> Hi All,
>
> I am trying to add some tracking code to my OpenLayers app so I can track
> performance of ajax requests. So my plan was to decorate the
> OpenLayers.Request.issue function to log the time before and after the
> issue().
>
> Something like:
>
> function decorateOpenLayersAjax(f) {
>   var startT = new Data();
>   var answer = f.apply(this, arguments);
>   try {
>     var deltaT = ((new Date()).getTime() - startT.getTime())/1000.0;
>     logtime(deltaT);
>   }
>   finally {
>     return answer;
>   }
> }
>
> And then in my init() function:
>
> OpenLayers.Request.issue = decorateOpenLayersAjax(**
> OpenLayers.Request.issue);
>
> My page loads fine, but on the first ajax request I get the error:
>
> TypeError: a.headers is undefined
>
> which implies that my decoration is breaking the code in:
>
> "ol212/lib/OpenLayers/Request.**js" line 165
>
>     issue: function(config) {
>         // apply default config - proxy host may have changed
>         var defaultConfig = OpenLayers.Util.extend(
>             this.DEFAULT_CONFIG,
>             {proxy: OpenLayers.ProxyHost}
>         );
>         config = OpenLayers.Util.applyDefaults(**config, defaultConfig);
>
> It seems that this.DEFAULT_CONFIG no longer points to the original object
> where it is defined.
>
> Any ideas on how to do this, or a better way to do this would be
> appreciated.
>
> -Steve
> ______________________________**_________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/openlayers-**users<http://lists.osgeo.org/mailman/listinfo/openlayers-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130202/587c8936/attachment.html>


More information about the Users mailing list