Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/01/2009, 09:47
buddysistemas
 
Fecha de Ingreso: enero-2009
Mensajes: 1
Antigüedad: 15 años, 4 meses
Puntos: 0
De acuerdo Respuesta: Ayuda formulario Ajax + Mootools

hola ajalex, mira tengo una pequeña duda yo estoy usando la clase mootools 1.2.1, y estoy usando el plugin accordion; hasta ahi todo va bien pero quiero implementar el efecto Timed Ajax que lo puedes ver en esta direccion: http://demos111.mootools.net/Ajax_Timed
mi problema es que cuando uso el javascript para ejecutar hace instancia a la clase Ajax y despues de haberla buscado en mi archivo mootools.js no la encuentro, hice un script basandome en los metodos que usa mi archivo pero sigue sin funcionar, este es el codigo:

utilrefresh.js

function refrescar(url){

// establecemes el periodo de refresco en 10 segundos
var timer = 5;
// periodical and dummy variables for later use
var periodical, dummy;
var start = $('start'), stop = $('stop'), log = $('yui-u');

/* our ajax istance */
var ajax = new Ajax(url, {
update: log,
method: 'get',
onComplete: function() {
// when complete, we remove the spinner
log.removeClass('ajax-loading');
},
onCancel: function() {
// when we stop timed ajax while it's requesting
// we forse to cancel the request, so here we
// just remove the spinner
log.removeClass('ajax-loading');
}
});

/* our refresh function: it sets a dummy to prevent
caching of php and add the loader class */
var refresh = (function() {
// dummy to prevent caching of php
dummy = $time() + $random(0, 100);
// we add out fancy spinner
log.empty().addClass('ajax-loading');
// requests of our php plus dummy as query
ajax.request(dummy);
});

// start and stop click events
//Cambiamos a un evento que se dispare automaticamente: window
//start.addEvent('click', function(e) {
window.addEvent('click', function(e) {
// prevent default
new Event(e).stop();
// prevent insane clicks to start numerous requests
$clear(periodical);

/* a bit of fancy styles */
//stop.setStyle('font-weight', 'normal');
//start.setStyle('font-weight', 'bold');
log.empty().addClass('ajax-loading');
/* ********************* */

// the periodical starts here, the * 1000 is because milliseconds required
periodical = refresh.periodical(timer * 1000, this);

// this is the first only request, later on will be only the periodical and refresh
// that do the request. If we don't do this way, we have to wait for 4 seconds before
// the first request.
ajax.request($time());
});

//stop.addEvent('click', function(e) {
// new Event(e).stop(); // prevent default;

/* a bit of fancy styles
note: we do not remove 'ajax-loading' class
because it is already done by 'onCancel'
since we later do 'ajax.cancel()'
*/
// start.setStyle('font-weight', 'normal');
// stop.setStyle('font-weight', 'bold');
/* ********************* */

// let's stop our timed ajax
/// $clear(periodical);
// and let's stop our request in case it was waiting for a response
// ajax.cancel();
//});
}
//Function de AJAX para la respuesta del servidor
function Ajax(){
var http=createRequestObject();var objectId='';function createRequestObject(htmlObjectId){var obj;var browser=navigator.appName;objectId=htmlObjectId;if (browser=="Microsoft Internet Explorer"){obj=new ActiveXObject("Microsoft.XMLHTTP");}
else{obj=new XMLHttpRequest();}
return obj;}
function sendReq(serverFileName,variableNames,variableValue s){var paramString='';variableNames=variableNames.split(' ,');variableValues=variableValues.split(',');for(i =0;i<variableNames.length;i++){paramString+=variab leNames[i]+'='+variableValues[i]+'&';}
paramString=paramString.substring(0,(paramString.l ength-1));if(paramString.length==0){http.open('get',serv erFileName);}
else{http.open('get',serverFileName+'?'+paramStrin g);}
http.onreadystatechange=handleResponse;http.send(n ull);}
function handleResponse(){if(http.readyState==4){responseTe xt=http.responseText;document.getElementById(objec tId).innerHTML=responseText;}}
}


en esta clase no estoy usando start ni stop, sino que lo pongo en el cargado de windows directamente, notaras esa diferencia cuando entres al link de Time_Ajax.
Espero tu respuesta prontamente, gracias..