Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/06/2008, 18:39
rodrigo_lopez
 
Fecha de Ingreso: diciembre-2002
Ubicación: arica 3334
Mensajes: 75
Antigüedad: 21 años, 4 meses
Puntos: 0
Respuesta: Duda con innerHTML

Esto te va a funcionar:

archivo.js
Código PHP:
function objetus(file) {

    
xmlhttp=false;
    
this.AjaxFailedAlert "Su navegador no soporta las funcionalidades de este sitio. Por favor habilite javascript en su navegador para verlo normalmente.\n";
    
this.requestFile file;
    
this.encodeURIString true;
    
this.execute false;
    
    if (
window.XMLHttpRequest) {
        
this.xmlhttp = new XMLHttpRequest();
        if (
this.xmlhttp.overrideMimeType) {
            
this.xmlhttp.overrideMimeType('text/xml');
        }

    } else if (
window.ActiveXObject) { // IE

        
try {
            
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (
e) {
            try {
                
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (
e) {
                
this.xmlhttp null;
            }
        }

        if (!
this.xmlhttp && typeof XMLHttpRequest!='undefined') {
            
this.xmlhttp = new XMLHttpRequest();
            if (!
this.xmlhttp){
                
this.failed true;
            }
        }
    } 
// end else if

    
return this.xmlhttp ;
}

function 
enviar(_pagina,valorget,valorpost,capa){

    
ajax=objetus(_pagina);

    if(
valorpost!=""){
        
ajax.open("POST"_pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
    } else {
        
ajax.open("GET"_pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
    }

    
ajax.onreadystatechange=function() {
        if (
ajax.readyState==1){
            
document.getElementById(capa).innerHTML "cargando...";
        }

        if (
ajax.readyState==4) {

            if(
ajax.status==200){
                
document.getElementById(capa).innerHTML ajax.responseText;
            } else if(
ajax.status==404){
                
capa.innerHTML "La direccion no existe";
            } else {
                
capa.innerHTML "Error: ".ajax.status;
            }
        }
    }
    
    if(
valorpost!=""){
        
ajax.setRequestHeader("Content-Type""application/x-www-form-urlencoded");
        
ajax.send(valorpost);
    } else {
        
ajax.send(null);
    }

luego desde tu pagina llamalo de esta forma:
<script language="javascript" src="archivo.js"></script>

y los enlaces:

<a href="javascript:enviar('paginaquerecibiravariables.php','tipo=gettt','tipost=post&tipo2=post2','identificador')">

con eso enviaras variables a paginaquerecibiravariables.php.

como metodo get: $_GET['tipo'] = será (gettt) como valor
como metodo post $_POST['tipost'] = será (post) y $_POST['tipo2'] = será (post2) como valor

todo eso se cargara en el div que quieres que tienes que agregarle: id="identificador"

ejemplo:

<div id="identificador"></div>

me explique bien?
__________________
Rodrigo Lopez