
Untitled
By: a guest on
May 11th, 2012 | syntax:
None | size: 1.09 KB | hits: 15 | expires: Never
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function cargar_asincrono(){
//Creamos una variable cada vez que se ejecute la funcion
el_objeto=null;
//Ahora asignamos a la variable nuestro objeto
el_objeto=new XMLHttpRequest();
//Configuramos nuestro objeto open(metodo,ubicacion,asyncrono)
el_objeto.open('GET','externo.htm','true');
//Enviamos la peticion
el_objeto.send();
//usamos el evento handler para ejecutar la funcion escribir en cada cambio de estado.
el_objeto.onreadystatechange=escribir;
function escribir(){
if(el_objeto.readyState==4);{
document.getElementById('salida').innerHTML=el_objeto.responseText;
}
}
}
</script>
</head>
<body>
<div id="salida"></div>
<input type="button" value="Cargar contenido de externo.html" onclick="cargar_asincrono('artistas.php')"/>
</body>
</html>