Ver Mensaje Individual
  #8 (permalink)  
Antiguo 12/10/2005, 16:25
Spyn_ET
 
Fecha de Ingreso: diciembre-2003
Mensajes: 218
Antigüedad: 20 años, 4 meses
Puntos: 0
Muchas gracias, por la info!!!

Teneis alguna idea de como podria saber si un objeto es form o no? Es q he modificado la clase, y claro despues de esto tendre q volver a hacerlo. Y dependiendo del tipo de objeto q haya de modificar hacer un .value o un innerHTML.

Código PHP:
<?

class objAjax
{
    var 
$url;
    var 
$codigo ="";
    var 
$entrada "";
    var 
$salida "";
    var 
$formato 'GET';
    
    
/********************************************************/
    /*    Constructor                                            */
    /*        - $entrada     --> Parametro de entrada            */
    /*        - $salida     --> Donde colocamos los datos        */
    /*        - $url     --> Url de donde cargamos datos            */
    /*        - $formato     --> GET o POST                        */
    /********************************************************/
    
function objAjax($entrada$salida,$url,$formato 'GET')
    { 
        
$this->url $url;
        
$this->entrada $entrada;
        
$this->formato $formato;
        
$this->Carga($salida);
    }
    
/********************************************************/
    /*    CreaCabecera                                        */
    /********************************************************/
    
function CreaCabecera()
    {
        
$this->codigo "<script>";
        
$this->codigo .= "function createRequestObject()\n";
        
$this->codigo .= "{\n";
        
$this->codigo .= "var request_;\n";
        
$this->codigo .= "var browser = navigator.appName;\n";
        
$this->codigo .= "if(browser == \"Microsoft Internet Explorer\"){\n";
        
$this->codigo .= "request_ = new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
        
$this->codigo .= "}else{\n";
        
$this->codigo .= "request_ = new XMLHttpRequest();\n";
        
$this->codigo .= "}\n";
        
$this->codigo .= "return request_;\n";
        
$this->codigo .= "}\n";
                
$this->codigo .= "var http = createRequestObject();\n";
        
$this->codigo .= "var url = '".$this->url."';\n";
        
/*********************************************/
        
$this->codigo .= "// Funcion q reemplaza el texto\n";
        
$this->codigo .= "function replaceHTML(idName, content)\n";
        
$this->codigo .= "{\n";
        
$this->codigo .= "    var target = document.getElementById(idName); \n";   
        
$this->codigo .= "    target.innerHTML = content;\n"
        
$this->codigo .= "}\n";[/B]
        
/*********************************************/
    
}
    
/********************************************************/
    /*    LeeDatos                                            */
    /********************************************************/
    
function LeeDatos()
    {
            
        if (
$this->formato == 'GET')
        {
            
$this->codigo .= "function getInfo(valor){\n";
            if (
$this->entrada != '')
                {
                
$this->codigo .= "valor = document.getElementById('".$this->entrada."').value;";
                
$this->codigo .= "    http.open('get', '".$this->url."?".$this->entrada."=' + valor);\n";
                }
            else
                
$this->codigo .= "    http.open('get', '".$this->url."' + valor);\n";
            
$this->codigo .= "    http.onreadystatechange = handleInfo;\n";
            
$this->codigo .= "    http.send(null);\n";
            
$this->codigo .= "}\n";
        }
        else
            {
            
$this->codigo .= "function getInfo(valor){\n";
            
$this->codigo .= "    http.open('POST', '".$this->url."',true);\n";
            
$this->codigo .= "    http.onreadystatechange = handleInfo;\n";
            
$this->codigo .= "    http.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\n";
            if (
$this->entrada != '')
                {
                
$this->codigo .= "    valor = document.getElementById('".$this->entrada."').value;\n";
                
$this->codigo .= "    http.send('".$this->entrada."=' + valor);\n";
                }
            else
                
$this->codigo .= "    http.send(null);\n";
            
$this->codigo .= "}\n";
            }
    }
    
/********************************************************/
    /*    EscribeDatos                                        */
    /*        - $div     --> Donde volcamos los datos            */
    /********************************************************/
    
function EscribeDatos($div)
    {
        
/*Funcion q muestra el resultado*/
        
$this->codigo .= "function handleInfo(){\n";
        
$this->codigo .= "    if(http.readyState == 1){\n";
        
$this->codigo .= "        replaceHTML('".$div."', 'Me estoy cargando...');\n";
        
$this->codigo .= "    }\n";
        
$this->codigo .= "    if(http.readyState == 4){\n";
        
$this->codigo .= "        replaceHTML('".$div."', http.responseText);\n";
        
$this->codigo .= "    }\n";
        
$this->codigo .= "}\n";
    }

    
/********************************************************/
    /*    Carga                                                */
    /*        - $en     --> Donde volcamos los datos            */
    /********************************************************/
    
function Carga($en)
    {
        
$this->CreaCabecera();
        
$this->LeeDatos();
        
$this->EscribeDatos($en);
        
$this->codigo .= "</script>\n";
    }

    
/********************************************************/
    /*    Muestra                                                */
    /********************************************************/
    
function Muestra ()
    {
        return 
$this->codigo;
    }
}
__________________
SymbianForever
SymbianForever.com, todo sobre y para tu symbian
aNieto2K | Themes para WordPress
De todo un poco