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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:50:12+00:00 2026-05-28T16:50:12+00:00

Actually I am having a global JSON, when I am trying to parse its

  • 0

Actually I am having a global JSON, when I am trying to parse its value in loop, it is showing me error “uncaught type error : Cannot read value ‘name’ of undefined”. I have tried a lot but I am still not able to figure out any solution for it.

    $(document).ready(function(){   

var productJSON = [
                    {id:"1001",name:"Hopper1",image:"images/290161k.jpg"},
                    {id:"1002",name:"Hopper2",image:"images/290161k.jpg"},
                    {id:"1003",name:"Hopper3",image:"images/290161k.jpg"},
                    {id:"1004",name:"Hopper4",image:"images/290161k.jpg"},
                    {id:"1005",name:"Hopper5",image:"images/290161k.jpg"},
                    {id:"1006",name:"Hopper6",image:"images/290161k.jpg"},
                    {id:"1007",name:"Hopper7",image:"images/290161k.jpg"},
                    {id:"1008",name:"Hopper8",image:"images/290161k.jpg"}
                  ];
var a=0;
for(var i=0;i<productJSON.length;i++){
    var pagedisplay = '';
    for(var j=0;j<2;j++){
            var generatedProductDisplay = '';

            generatedProductDisplay = '<div id="'+productJSON[a].id+'" class="productDiv"><a class="productLink" href="#"><center><div class="productImage"><img src="'+productJSON[a].image+'" width="100%" height="200px" alt="'+productJSON[a].name+'"></div><div><p class="productName">'+productJSON[a].name+'</p></div></center></a></div>';

            pagedisplay = pagedisplay+generatedProductDisplay;
            a++;
        }
        pagedisplay = pagedisplay+'<br/>';
        $(".productDisplay").append(pagedisplay);
    }   

$(".productDiv").live("click",function(){
    alert("Hello"); 
});
   });

This is the HTML code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to Nitin Agro Industries, Chhatarpur</title>
<link href="styles/main.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"
type="text/javascript"></script>
<script src="productsDisplay.js" type="text/javascript"></script>

</head>

 <body>
 <center>
 <div class="page-wrap">
    <div class="centerContent">
  <h1>Explore our Product Catalog</h1>
  <div class="centerText">
    <center>
      <div class="hideShowDiv">
        skdddddddddddd
      </div>
      <div class="productDisplay"></div>
    </center>
  </div>
</div>
</div>
</center>
</body>
</html>
  • 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-28T16:50:14+00:00Added an answer on May 28, 2026 at 4:50 pm

    It means that the property is not defined at that point. So check if you have defined the property.

    The question obviously needs the source-code to be answered. Please put them.

    EDIT

    Its an out of bound problem. Change this line:

    generatedProductDisplay = '<div id="'+productJSON[a].id+'" class="productDiv"><a class="productLink" href="#"><center><div class="productImage"><img src="'+productJSON[a].image+'" width="100%" height="200px" alt="'+productJSON[a].name+'"></div><div><p class="productName">'+productJSON[a].name+'</p></div></center></a></div>';
    

    a contains value out of the range of the array. Change it to i.

    As you have not stated your logic. I assume that the inner loop does nothing (from what i can derive) and suggest this:

    for(var i=0;i<productJSON.length;i++){
        var pagedisplay = '';
            var generatedProductDisplay = '';
    
            generatedProductDisplay = '<div id="'+productJSON[i].id+'" class="productDiv"><a class="productLink" href="#"><center><div class="productImage"><img src="'+productJSON[i].image+'" width="100%" height="200px" alt="'+productJSON[i].name+'"></div><div><p class="productName">'+productJSON[i].name+'</p></div></center></a></div>';
    
            pagedisplay = pagedisplay+generatedProductDisplay;
            pagedisplay = pagedisplay+'<br/>';
            $(".productDisplay").append(pagedisplay);
        }   
    

    EDIT 2

    As i still didnt understand your inner loop, here is my take on it:

    Without inner loop:

    http://jsfiddle.net/guSLL/
    $(document).ready(function() {
    
        var productJSON = [
            {
            id: "1001",
            name: "Hopper1",
            image: "images/290161k.jpg"},
        {
            id: "1002",
            name: "Hopper2",
            image: "images/290161k.jpg"},
        {
            id: "1003",
            name: "Hopper3",
            image: "images/290161k.jpg"},
        {
            id: "1004",
            name: "Hopper4",
            image: "images/290161k.jpg"},
        {
            id: "1005",
            name: "Hopper5",
            image: "images/290161k.jpg"},
        {
            id: "1006",
            name: "Hopper6",
            image: "images/290161k.jpg"},
        {
            id: "1007",
            name: "Hopper7",
            image: "images/290161k.jpg"},
        {
            id: "1008",
            name: "Hopper8",
            image: "images/290161k.jpg"}
        ];
        for (var i = 0; i < productJSON.length; i++) {
            var pagedisplay = '';
            generatedProductDisplay = '<div id="' + productJSON[i].id + '" class="productDiv"><a class="productLink" href="#"><center><div class="productImage"><img src="' + productJSON[i].image + '" width="100%" height="200px" alt="' + productJSON[i].name + '"></div><div><p class="productName">' + productJSON[i].name + '</p></div></center></a></div>';
            pagedisplay = pagedisplay + generatedProductDisplay;
            pagedisplay = pagedisplay + '<br/>';
            $(".productDisplay").append(pagedisplay);
        }
    
        $(".productDiv").live("click", function() {
            alert("Hello");
        });
    });
    

    With inner loop:

    http://jsfiddle.net/guSLL/1/

    $(document).ready(function() {
    
        var productJSON = [
            {
            id: "1001",
            name: "Hopper1",
            image: "images/290161k.jpg"},
        {
            id: "1002",
            name: "Hopper2",
            image: "images/290161k.jpg"},
        {
            id: "1003",
            name: "Hopper3",
            image: "images/290161k.jpg"},
        {
            id: "1004",
            name: "Hopper4",
            image: "images/290161k.jpg"},
        {
            id: "1005",
            name: "Hopper5",
            image: "images/290161k.jpg"},
        {
            id: "1006",
            name: "Hopper6",
            image: "images/290161k.jpg"},
        {
            id: "1007",
            name: "Hopper7",
            image: "images/290161k.jpg"},
        {
            id: "1008",
            name: "Hopper8",
            image: "images/290161k.jpg"}
        ];
        for (var i = 0; i < productJSON.length;) {
    
            var pagedisplay = '';
            for (j = 0; j < 2 && i < productJSON.length; j++, i++) {
                generatedProductDisplay = '<div id="' + productJSON[i].id + '" class="productDiv"><a class="productLink" href="#"><center><div class="productImage"><img src="' + productJSON[i].image + '" width="100%" height="200px" alt="' + productJSON[i].name + '"></div><div><p class="productName">' + productJSON[i].name + '</p></div></center></a></div>';
                pagedisplay = pagedisplay + generatedProductDisplay;
                pagedisplay = pagedisplay + '<br/>';
    
            }
            $(".productDisplay").append(pagedisplay);
        }
    
        $(".productDiv").live("click", function() {
            alert("Hello");
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to make an app with geoDjango but I'm actually having some problem
I am actually having a list of text boxes. I am using below code
Are there any free libraries that would print to a PDF without actually having
I'm having a rare CSS issue in Internet Explorer 7 (I'm actually testing it
I'm having a hard time conceptualizing c++ sets, actually sets in general. What are
Actually here is a similar topic with little practical value. As far as I
Actually what i am trying to build is like a kind of firewall. It
Actually I am trying to move some box alternatively with in another box. I
Sorry if this seems like a stupid question but im actually having a hard
I am having a memory leak problem and it is actually generating from 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.