Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
Creating a GET request to display images from JSON file

I'm new to Javascript and have been spinning on writing this piece of code in order to display a series of pictures on a page from an external source, sort of like an instagram feed, using a GET request through jQuery. I have been given a JSON file that contains an array of image URLs, some of which I want to exclude because they are broken.

Here is the code that I've written thus far - I've tested it and it doesn't work and I'm looking for some guidance on what aspects I may be missing in order to get my code to work:

$(document).ready(function () {
    $('imagesFromJSON').click(function () {
        $.getJSON("images.json", function (data) {

            var arrItems = [];      // The array to store JSON items.
            $.each(data, function (index, value) {
            arrItems.push(value);       // Push values in the array.
            });

            for (let i = 0; i < arrItems.length; i++) {
                if (arrItems[i].contains('fakeurl') === false) {
                let img = document.createElement('img');
                img.src = arrItems[i].Image
                document.querySelector('.container').appendChild(image)
                }
            }
        });
    });
});
<html>
<head>
  <meta charset="UTF-8">
  <title>Feed Test</title>
  <script type='text/javascript' src='feed.js'></script>
  <script src="jquery-3.6.0.min.js"></script>
</head>

<body>

<h1>FEED TEST</h1>

<p><input type="button" id= "imagesFromJSON" value="Show Images" /></p>

<div class="container"></div>

</body>
</html>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda