Ver Mensaje Individual
  #17 (permalink)  
Antiguo 14/04/2008, 08:06
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Problema al redireccionar a otra pagina, al finalizar llamada Ajax

Mmmm es raro, al parecer con cada llamada ocupa la pasada y no crea un nuevo número aleatorio, a ver prueba esto:
Código:
Ajax.PeriodicalAjax = Class.create(Ajax.Base, {
  initialize: function($super, url, options) {
    $super(options);
    this.onComplete = this.options.onComplete;

    this.frequency = (this.options.frequency || 2);
    this.decay = (this.options.decay || 1);

    this.updater = { };
    this.url = url;

    this.start();
  },

  start: function() {
    this.options.onComplete = this.updateComplete.bind(this);
    this.onTimerEvent();
  },

  stop: function() {
    this.updater.options.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  },

  updateComplete: function(response) {
    if (this.options.decay) {
      this.decay = (response.responseText == this.lastText ?
        this.decay * this.options.decay : 1);

      this.lastText = response.responseText;
    }
    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
  },

  onTimerEvent: function() {
    var pars = ( this.options.parameters || {} );
    pars['__r'] = Math.random();
    this.options.parameters = pars;
    this.updater = new Ajax.Request(this.url, this.options);
  }
});

function Rellenar_Bd( url ) {
	$('contenedor').style.height="650px";
	Element.show('contenedor');
	
	new Ajax.PeriodicalAjax(url, {
		method: 'get', 
		frequency: 0.7,
		decay: 1,
		onSuccess: function(res) {
			if( res.responseText == "1" ) {
				this.stop();
                                setTimeout( function() {
                                          Element.hide('loading_tablas');
				          window.location = 'index.php?seccion=2&act=3';
                                }, 1000 );
			}
		}
	});
}
Saludos.