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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:00:32+00:00 2026-06-15T10:00:32+00:00

I have a JSON object that I parse using jQuery’s parseJSON function. I assign

  • 0

I have a JSON object that I parse using jQuery’s parseJSON function. I assign one of the child objects to a local variable which I then iterate over using a for loop as follows:

var posts = feedObj["posts"];
content+= "<h2 title=\"" + feedDescription + "\"><a href=\"" + feedPermalink + "\">" + feedTitle + "</a></h2>";
content+= "<ul class=\"feedList\">";
for (var i = 0; i < 10; i++) {
     console.log(posts[i]["postTitle"]);
     var postTitle = posts[i]["postTitle"];
     if((typeof posts[i] != "undefined") || postTitle != null) {
          content+= "<li>";
          console.log("AJ::PostTitle"+postTitle);
          content+= "<a href=\"" + decodeURIComponent(posts[i]["permaLink"])  + "\" target=\"_blank\">" + unescapeHTML(postTitle) + "</a>";
           content+= "</li>";
     }
}

For some reason, the var postTitle = posts[i]["postTitle"]; always gives the following error:
Uncaught TypeError: Cannot read property 'postTitle' of undefined

I have no idea why this is happening. The console statement prints out the postTitle correctly but the assignment always fails. What am I doing 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-06-15T10:00:33+00:00Added an answer on June 15, 2026 at 10:00 am

    Instead of

    for (var i = 0; i < 10; i++) {
    

    Add the check condition for the array object

    for (var i = 0; i < posts.length ; i++) {
    

    Maybe the array you are referring to might not have 10 entries in it. The later approach should solve the problem..

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

Sidebar

Related Questions

I have a 2 MB JSON object that I'm hoping to parse with jQuery.
I have a controller method that returns a jSON object and in one calling
I'm using Qjson to parse a json object that is returned from a web
I have a few jQuery plugins that I made - all parse JSON feeds
I have a function that parse a JSON text and return a new structure
I have a json object that looks something like this: Array ( [algorithm] =>
I have a JSON Object that is returned from a web service call that
For example lets say I have a JSON object that contains states and cities.
I have a nested JSON object that I need to loop through, and the
I have a json object collection of geo locations that I build in the

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.