Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/10/2005, 06:50
Spyn_ET
 
Fecha de Ingreso: diciembre-2003
Mensajes: 218
Antigüedad: 20 años, 4 meses
Puntos: 0
Bueno, he estado pensando en el tema y creo q esta es la mejor manera (ahora no veo otra) para poder hacer el codigo lo mas reutilizable posible.

Código PHP:
var COMPLETE    4;
var 
LOADING        1;
/**************************************************************
Funcion Objetus de maborak
    http://69.56.196.226/~maborak/leimnud/index.php?
    
**************************************************************/
function objetus() {
        try {
                
objetus = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (
e) {
                try {
                        
objetus= new ActiveXObject("Microsoft.XMLHTTP");
                } catch (
E) {
                        
objetusfalse;
                }
        }
        if (!
objetus && typeof XMLHttpRequest!='undefined') {
                
objetus = new XMLHttpRequest();
        }
        return 
objetus
}

function 
LeeDatos(url,val,tipo,salida)
{
    var 
result "";
    
_objetus=objetus() //crear objeto
    
_values_sendval //variables
    
_URL_url+"?" //URL
    
    
if ( tipo == 'post')                    // Pasamos las variables POST 
        
{
        
_objetus.open("POST",_URL_,true); //abrir procesador
_objetus.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); //cabeceras POST
        
_objetus.send('&'+_values_send); //enviar variables
        
}
    else if (
tipo == 'get')                    // Pasamos las variables por GET
        
_objetus.open("GET",_URL_+"&"+_values_send,true); //abrir procesador
        
    
_objetus.onreadystatechange=function() {             //funcion controlador
    
if (_objetus.readyState==COMPLETE//control de estados del proceso
        
{
                  if(
_objetus.status==200)//si se da un status 200 (TERMINADO CON EXITO)
                    
{
                        if  (
salida == 'XML')                    // Si el tipo es XML
                            
result _objetus.responseXML;                                
                        else
                            
result _objetus.responseText;        // Si el tipo no es XML
                    
}
        }
    }
    
_objetus.send(null); //envío nulo de variables
    
fncAccion(result);

Y luego para usarlo primero, habria q deblarar una funcion q se llame fncAccion(var);
Y dentro realizamos lo q queramos con el resultado q obtenemos de LeeDatos.

<b>index.html</b>
Código PHP:
<html>
<
head>
<
titlePrueba</title>
<
script>
fncAccion(content)
{
var 
target document.getElementById("my_div"); 
target.innerHTML content;
}
</script>
<script src="objAjax.js" ></script>
</head>
<body>
<input name="nombre" id="algo" onChange="LeeDatos("datos.php","id=","GET","text");" />
<div id="my_div"></div>
</body>
</html> 
No lo he probado, es solo una idea q tenia en la cabeza? Q os parece?
__________________
SymbianForever
SymbianForever.com, todo sobre y para tu symbian
aNieto2K | Themes para WordPress
De todo un poco