Skip to content

Instantly share code, notes, and snippets.

@evilnapsis
Created January 17, 2017 22:38
Show Gist options
  • Save evilnapsis/062479e57145774650a182b39a0f1ec9 to your computer and use it in GitHub Desktop.
Save evilnapsis/062479e57145774650a182b39a0f1ec9 to your computer and use it in GitHub Desktop.
Ejemplo de Index para el primer ejemplo de Aprender AJAX by Evilnapsis
<!DOCTYPE html>
<html>
<head>
<title>Ejemplo de AJAX #1</title>
</head>
<body>
<h1>Ejemplo de AJAX #1</h1>
<a href="#" id="cargar1" onclick="cargar1()">Cargar pagina 1</a>
<a href="#" id="cargar2" onclick="cargar2()">Cargar pagina 2</a>
<div id="contenedor" style="border: 1px black solid;">
<h1>El contenido se agregara AQUI</h1>
</div>
<script>
function cargar1(){
xhr = new XMLHttpRequest();
xhr.open("GET","page1.php",false);
xhr.send();
con = document.getElementById("contenedor");
con.innerHTML = xhr.responseText;
}
function cargar2(){
xhr = new XMLHttpRequest();
xhr.open("GET","page2.php",false);
xhr.send();
con = document.getElementById("contenedor");
con.innerHTML = xhr.responseText;
}
</script>
<h3>Powered by <a target="_blank" href="http://evilnapsis.com/">Evilnapsis</a></h3>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment