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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:12:34+00:00 2026-06-12T13:12:34+00:00

I get the following string: [{Key:1,Value:correct},{Key:2,Value:incorrect},{Key:3,Value:incorrect},{Key:4,Value:correct},{Key:5,Value:incorrect}] I want to change the background color of

  • 0

I get the following string:

[{"Key":1,"Value":"correct"},{"Key":2,"Value":"incorrect"},{"Key":3,"Value":"incorrect"},{"Key":4,"Value":"correct"},{"Key":5,"Value":"incorrect"}]

I want to change the background color of my TR based on whether the ID of that TR has a value of “correct” or “incorrect” in the JSON.

How can I get the value of an individual item from JSON? I have tried:

            success: function (result) {
                // update with results
                //alert(JSON.stringify(result));
                //$('#myDiv').html(JSON.stringify(result));

                // non of these work
                alert(result[0]);
                alert(result[key]);
            },
  • 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-06-12T13:12:36+00:00Added an answer on June 12, 2026 at 1:12 pm

    You can use $.each() to iterate the Array of Objects.

    $.each(result, function(i, item) {
        alert(item.Key);
    });
    

    In the callback to $.each(), item will be a reference to the current item in the Array being iterated.

    Then you just use normal property access to get the value for the Key property.


    Of course you could also use a traditional for statement to loop the Array.

    for (var i = 0; i < result.length; i++) {
        var item = result[i];
        alert(item.Key);
    }
    

    All of this assumes your response has the proper Content-Type setting, or you’ve give dataType:"json" to $.ajax().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSON string that contains some key with the following value: 123.00.
I get the following text as a string from an XML-based REST API 'd':4
Suppose I have a string that looks like the following: string foo =<add key=key1
Initial conditions: DateTime moment string key double value somewhere across the code i want
I have the following string fromat: session=11;reserID=1000001 How to get string array of number?
I currently have the following Get-ChildItem -recurse -include file.ext | Select-String -pattern c: |
I'm trying to get the following regex to work on my String: Pattern Regex
I have the following code: String website = http://www.somewebsite.com/; Document doc = Jsoup.connect(website).get(); Elements
I #include <string.h> but when I call strcasestr(src, search); I get the following error
Take the following property: public string Foo { get; private set; } Using reflection,

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.