Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript">
  7. function cargar_asincrono(){
  8.        
  9.         //Creamos una variable cada vez que se ejecute la funcion
  10. el_objeto=null;
  11.         //Ahora asignamos a la variable nuestro objeto
  12. el_objeto=new XMLHttpRequest();
  13.         //Configuramos nuestro objeto open(metodo,ubicacion,asyncrono)
  14. el_objeto.open('GET','externo.htm','true');
  15.         //Enviamos la peticion
  16. el_objeto.send();
  17.         //usamos el evento handler para ejecutar la funcion escribir en cada cambio de estado.
  18. el_objeto.onreadystatechange=escribir;
  19.        
  20.        
  21. function escribir(){
  22.         if(el_objeto.readyState==4);{
  23. document.getElementById('salida').innerHTML=el_objeto.responseText;
  24.                
  25.         }
  26.         }      
  27.        
  28.         }
  29. </script>
  30. </head>
  31.  
  32. <body>
  33. <div id="salida"></div>
  34. <input type="button" value="Cargar contenido de externo.html" onclick="cargar_asincrono('artistas.php')"/>
  35. </body>
  36. </html>