Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6527819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:28:38+00:00 2026-05-25T09:28:38+00:00

Hello I’m having some problem: I some data coming from a JSON file, and

  • 0

Hello I’m having some problem:
I some data coming from a JSON file, and I need to write it in a more efficient manner. Basically its working fine, but I will like to put the images in like a nested array or something.

So I just only have to do one image tag call, but the image tag will be bringing in a Set of Images. I don’t want to define image1-image1000 img tags,

I should be able to just put in the images like this:

“image”: { image1.jpg, image2.jpg, image3.jpg, image4.jpg}

and call it with one image tag like this

It that possible??? Some guidance will be helpful. Thanks

JSON DATA

{   "mygallery": [
            {"image1": " image1.jpg",
            "image2": " image2.jpg",
            "image3": " image 3.jpg",
            "image4": " image 4.jpg",
            “pagename”: “MyGallery”,
    }




JAVASCRIPT CALL

<script type="text/javascript">
$.getJSON('js/gallery.js, function(data){
         $("#main").html('');
         $(data.mygallery).each(function(index, mygallery){
             $("#main").append('<li class="thecontent"><img  src="/_img/' + mygallery.image1 + '"  /><img  src="/_img/' + mygallery.image2 + '"  /><img  src="/_img/' + mygallery.image3 + '"  /><img  src="/_img/' + mygallery.image4 + '"  /><span>' + mygallery.pagename + '</span></li>');
         });
     });



</script>



HTML DIV
<div id=”main”>




</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:28:38+00:00Added an answer on May 25, 2026 at 9:28 am

    You can create something like this which still keep all the images and pagename inside mygallery object.

    {   
       "mygallery": { images: [
                           "image1.jpg",
                           "image2.jpg",
                           "image3.jpg",
                           "image4.jpg",
                        ],
                       pagename: “MyGallery”
                     }
    }
    

    This is how you will use it

    $.getJSON('js/gallery.js', function(data){ 
          $("#main").html('<li class="thecontent">'); 
          var images = data.images;
          for(var i =0;i<images.length;i++){
             $("#main").append('<img src="/_img/' + images[i] + '" />'); 
          }
          //$.each(images function(index, image){ 
          //   $("#main").append('<img src="/_img/' + image + '" />'); 
          //}); 
    
          $("#main").append('<span>' + data.pagename + ' </span></li> ');
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello friends i am having problem in parsing jSON web services data I have
i m having problem in overwriting some data in a file in c++. the
hello i get some help here yesterday for a problem i was having tablesorter.
Hello I seem to be having some problem involving counting in Django. I have
I am having some problem while I am sending UDP packets from netcat or
Hello I am having a problem with the numbering of figures using Latex, I
Hello I'm having problems sending arrays, structs and arrays of structs from PHP to
Hello ladies and gents, I'm having a bit of problem with accept() . I
Hello i am having some problems generating random numbers with C# Now i have
I am having some problems trying to work with PostgreSQL and Hibernate, more specifically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.