Ver Mensaje Individual
  #13 (permalink)  
Antiguo 02/03/2010, 01:44
Avatar de JoseAlejandro_Realza
JoseAlejandro_Realza
 
Fecha de Ingreso: agosto-2008
Ubicación: Maracay - Venezuela
Mensajes: 192
Antigüedad: 15 años, 9 meses
Puntos: 2
Respuesta: ejecutar php desde javascript/html??

Si quieres utilizar Ajax para llamadas asincronicas es algo muy sencillo, acá te dejo un código de ejemplo para que lo pruebas y lo modifiques según sea conveniente:

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="es">   

 <head>  

  <title>Aprendiendo Ajax</title>  

</head>  

<script language="javascript"  type="text/javascript">  

  var RequestObject = false;   

  var Archivo = 'datos.php'; //archivo php de donde extraeremos los datos   

  window.setInterval("actualizar_datos()", 2000); // cada cuando tiempo se actualizara la información  

  if (window.XMLHttpRequest)  
   RequestObject = new XMLHttpRequest();  
      if (window.ActiveXObject)     
       RequestObject = new ActiveXObject("Microsoft.XMLHTTP");  
        function ReqChange() {   
              if (RequestObject.readyState==4) {  
                     if (RequestObject.responseText.indexOf('invalid') == -1)   
                     {     
                  var msgs = RequestObject.responseText.split('|');  
             // Aca sera el Div donde agregaras la información Nueva 
             document.getElementById("Datos").innerHTML = msgs[0];  
             }  
               else {   
              document.getElementById("Datos").innerHTML = "No se pude extraer la información";  
              }  
            }  
          }  


     function actualizar_datos() {  

         document.getElementById("Datos").innerHTML = "";  
           RequestObject.open("GET", Archivo , true);  
            RequestObject.onreadystatechange = ReqChange;     
           RequestObject.send(null);   
      }  


    function actualizar_datos() {  
    cargar_datos();  
    }  
</script>  

<body onload="cargar_datos();">  

<div class="ver_datos">Datos Almacenados</div>

  <div id="Datos"></div>  

</body>  

</html> 
Saludos
__________________
Tu Guía Empresarial http://www.empresarial.org.ve Soluciones Empresariales

Atte: José Alejandro Realza