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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:17:54+00:00 2026-05-25T03:17:54+00:00

I have a little app that pulls data from several API’s. In all of

  • 0

I have a little app that pulls data from several API’s. In all of my cases so far I get JSON back for a single response, but for this one I get an array of hits. How do I access the data in the array?? Here’s the basic structure of my javascript grabbing data from the returned JSON:

// pull article from JSON
function getArticle(article) {
  document.getElementById('articletitle').innerHTML = (article.title);
  ...
};

So that works great for a single response, it grabs the article title and throws it in a div. But what if I get back an array of articles like this

JSON:

getArticle({"Title":"title","Rights":"Copyright (C)",...[{"ResultId":1,"DocType":"ar","DocTitle":"some title",...

My main question is just how to grab say the DocTitle here of a given article? simply grabbing .DocTitle doesn’t seem to get through. BONUS POINTS for modifying the javascript to iterate through the array of articles returned too.

Thanks a million.

  • 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-25T03:17:55+00:00Added an answer on May 25, 2026 at 3:17 am

    In your question this:

    getArticle({"Title":"title","Rights":"Copyright (C)",...
    [{"ResultId":1,"DocType":"ar","DocTitle":"some title",... 
    

    Has been over-abbreviated to the point that we have to guess what you meant. You can’t have an array sitting in the middle of an object unless it is associated with a key. You need something like this:

    getArticle({"Title":"title","Rights":"Copyright (C)",...
        "articles" : [{"ResultId":1,"DocType":"ar","DocTitle":"some title",...]
    });
    
    function getArticle(article) {
       alert(article.articles[0].DocTitle); // first item in array: "some title"
    
       for (var i = 0; i < article.articles.length; i++) {
          var currentArticle = article.articles[i];
          alert(currentArticle.ResultId + ": " + currentArticle.DocTitle);
       }
    }
    

    Note I’ve added the key “articles” within your object.

    Or you can return an array on its own instead of as part of another object:

    getArticle([{"ResultId":1,"DocType":"ar","DocTitle":"some title",...},{"ResultId":2,...},...]);
    
    function getArticle(articles) {
       for (var i = 0; i < articles.length; i++)
          alert(articles[i].DocTitle);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little logging app (written in wxPython) that receives data from a
I have a little iPhone app that loads data from a web service. To
So I have a little app I am working on that scrapes comics from
I have an app that I've written in C#/WinForms ( my little app ).
I have a little one-liner in my Rails app that returns a range of
I am learning flex and have written a little app with a TextArea that
I have an app that I'm writing a little wizard for. It automated a
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a little app that runs fine on local dev appengine, but appengine
I have a little app that I want (potentially) a lot of my clients

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.