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

  • SEARCH
  • Home
  • 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 999345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:20:19+00:00 2026-05-16T07:20:19+00:00

I am retrieving some JSON data with the following function. It is called when

  • 0

I am retrieving some JSON data with the following function. It is called when an element is clicked and the data is used to create a table, populate the cells with images and append the table to a div.

function LoadImagesByCategory() {
    $.getJSON("/Service/GetJson.ashx?data=images", function(data) {
        jsObjectData = data.ImageCollection.Images;
        //Create a table named imageTable
        $("#imagesByCategory").append(imageTable);
        }
    })

the jsObjectData looks like this.

{"ImageCollection":
    {"Images":
    [{  "ImageID":"68",
        "CatID":"1",
        "Name":"uploadedFile",
        "Location":"/Images/Art/Full/68.gif",
        "ClipLocation":"/Images/Art/Clips/68.gif",
        "FullHeight":"504",
        "FullWidth":"451"
       },
       { "ImageID":"69",
         "CatID":"1",
         "Name":"uploadedFile",
         "Location":"/Images/Art/Full/69.gif",
         "ClipLocation":"/Images/Art/Clips/69.gif",
         "FullHeight":"364",
         "FullWidth":"500"
        },
        etc. etc 
     ]
   }
 }

It contains additional info about the images like the FullHeight and the FullWidth that I would like to be able to retrieve when an img is clicked.
For example if I made the id of the img something like “68ArtImage” where 68 is the ImageID I would like to be able to pass the 68 into a function attached to the jsObjectData and retrieve the corresponding Image Data.
The problems are first that I don’t know how to make the object avail. outside the function and second I don’t know how to attach the function to the object.

  • 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-16T07:20:20+00:00Added an answer on May 16, 2026 at 7:20 am

    After reading your question again, perhaps this is what you want?

    function getImageData(id, json){
        for(i in json.ImageCollection.Images){
           if( json.ImageCollection.Images[i].ImageID == 69){
                return json.ImageCollection.Images[i];
           }
        }
        return false;
    }
    

    getImageData will search the given json object and return the image object (like an associative array) if it exists, else false.

    Example:

    var json = {"ImageCollection":
        {"Images":
        [{  "ImageID":"68",
            "CatID":"1",
            "Name":"uploadedFile",
            "Location":"/Images/Art/Full/68.gif",
            "ClipLocation":"/Images/Art/Clips/68.gif",
            "FullHeight":"504",
            "FullWidth":"451"
           },
           { "ImageID":"69",
             "CatID":"1",
             "Name":"uploadedFile",
             "Location":"/Images/Art/Full/69.gif",
             "ClipLocation":"/Images/Art/Clips/69.gif",
             "FullHeight":"364",
             "FullWidth":"500"
            }
         ]
       }
     }
    
    function getImageData(id, json){
        for(i in json.ImageCollection.Images){
           if( json.ImageCollection.Images[i].ImageID == 69){
                return json.ImageCollection.Images[i];
           }
        }
        return false;
    }
    
    if(image = getImageData(69, json)){
        alert('found the image wooo!');
        // now do something with your image object
    }
    else{
        alert('no image with that id found');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I'm retrieving some data from a MySQL database table, but the problem is
I have been having some issues retrieving JSON data from a WCF service application
I am retrieving some data from a table in mysql. The values are stored
Hi im retrieving some data from a database using JSON and ajax. When i
So I'm retrieving some JSON data from a website and using the standard urlopen()
I am parsing JSON data and retrieving 3 values in each node, $.each($.parseJSON(data), function
I am trying to create some JSON to be used for displaying a chart
Can anybody help me with retrieving some elements from the following example text: sdfaasdflj
For some reason I'm having a problem retrieving data from my database. It leaves
i posted some data using tinymce (in a symfony project).while retrieving back how can

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.