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 6644611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:11:14+00:00 2026-05-26T00:11:14+00:00

I’ve seen many JQuery examples that make use of $.each to loop through a

  • 0

I’ve seen many JQuery examples that make use of $.each to loop through a JSON array. However, what need to do is individually grab items 0 – 3 and pass them to another function called “Search”. Here’s what I’ve come up with.

        $.getJSON("http://localhost:61741/binggame/play?cat=Body%20Parts", {
        tags: "English",
        tagmode: "any",
        format: "json"

    },


function (data) {

    Search(data.items[0], "Box1_Image");
    Search(data.items[1], "Box2_Image");
    Search(data.items[2], "Box3_Image");
    Search(data.items[3], "Box4_Image");
});

I’m fairly certain that data.items[] is not the correct syntax.

Here’s a sample of my JSON:

{"nouns":[
    {
        "ID":26,
        "Category":"Body Parts",
        "English":"muscle",
        "Pinyin":"gei yUk",
        "Image1":null,
        "Audio1":null
    },
    {
        "ID":27,
        "Category":"Body Parts",
        "English":"neck",
        "Pinyin":"gen",
        "Image1":null,
        "Audio1":null
    },
    {
        "ID":28,
        "Category":"Body Parts",
        "English":"nose",
        "Pinyin":"bei",
        "Image1":null,
        "Audio1":null
    },
    {
        "ID":29,
        "Category":"Body Parts",
        "English":"rib",
        "Pinyin":"lat gwt",
        "Image1":null,
        "Audio1":null
    }
]}

For this sample, the value of data.items[0] should be “muscle”, data.items[1] should be “neck”, data.items[2] should be “nose” and data.items[3] should be “rib”.

Can someone point out to me what I’ve done wrong?

  • 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-26T00:11:15+00:00Added an answer on May 26, 2026 at 12:11 am

    Can someone point out to me what I’ve done wrong?

    To start, there is no property names items in your JSON.


    If you want to get "muscle": data.nouns[0].English

    If you want to get "neck": data.nouns[1].English

    and so on:

    function (data) {
    
        Search(data.nouns[0].English, "Box1_Image");
        Search(data.nouns[1].English, "Box2_Image");
        Search(data.nouns[2].English, "Box3_Image");
        Search(data.nouns[3].English, "Box4_Image");
    });
    

    or, to stay DRYer:

    function (data) {
        var nouns = data.nouns;
    
        function getNoun(i) {
            return nouns[i].English;
        }
    
        Search(getNoun(0), "Box1_Image");
        Search(getNoun(1), "Box2_Image");
        Search(getNoun(2), "Box3_Image");
        Search(getNoun(3), "Box4_Image");
    });
    

    or better still:

    function (data) {
        var nouns = data.nouns;
    
        for (var i=0; i<4; i++) {
            Search(nouns[i].English, 'Box' + (i+1) + '_Image');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and

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.