title: OpenLayers http refresh callback function
body: <p>Here's a stripped down version of my code that reloads a KML file every 2 seconds. On each update, I want to have the camera pan to the layer's feature's extent but I can't figure out where to set the callback.</p>
  
  <pre><code>//set up ajax    
  var protocol = new OpenLayers.Protocol.HTTP({
      url: "feed.kml",
      format: new OpenLayers.Format.KML(),
      callback: function(){
          alert("here"); //never called
      }
  });
  
  //create refresher
  var refresh = new OpenLayers.Strategy.Refresh({force: true, active: true});
  
  //create layer for kml
  var trackLayer = new OpenLayers.Layer.Vector("KML", {
      strategies: [new OpenLayers.Strategy.Fixed(), refresh],
      protocol: protocol,
  });
  
  //add to map
  map.addLayer(trackLayer);
  
  //refresh the kml every 2 seconds
  setInterval(function(){
      refresh.refresh();      
      //pan to extent
      map.panTo(trackLayer.getDataExtent().getCenterLonLat());
  },2000);
  </code></pre>
  
  <p>the problem is that this line: <code>map.panTo(trackLayer.getDataExtent().getCenterLonLat());</code> is being called before the request is finished.</p>
  
  <p>Here's the docs:</p>
  
  <ul>
  <li><a href="http://dev.openlayers.org/docs/files/OpenLayers/Strategy/Refresh-js.html" rel="nofollow">http://dev.openlayers.org/docs/files/OpenLayers/Strategy/Refresh-js.html</a></li>
  <li><a href="http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html" rel="nofollow">http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html</a></li>
  <li><a href="http://dev.openlayers.org/docs/files/OpenLayers/Protocol/HTTP-js.html" rel="nofollow">http://dev.openlayers.org/docs/files/OpenLayers/Protocol/HTTP-js.html</a></li>
  </ul>