Created
September 24, 2019 16:59
-
-
Save parzibyte/905e7c77f3e65e503385a9e6dfaf127d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready( | |
function() { | |
const $btnCargarDatos = $("#btnCargarDatos"), | |
$respuesta = $("#respuesta"); | |
$btnCargarDatos.click(function() { | |
$.get("./datos.php", function(nombresCodificados) { | |
let nombres = JSON.parse(nombresCodificados); | |
// Limpiar el contenedor por si ya tenía datos | |
$respuesta.empty(); | |
// Cada nombre agregarlo usando forEach del arreglo | |
// https://parzibyte.me/blog/2019/09/24/foreach-javascript-recorrer-arreglos/ | |
nombres.forEach(nombre => { | |
$respuesta.append(nombre + "<br>"); | |
}); | |
}); | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment