Note that there are some explanatory texts on larger screens.

plurals
  1. POUncaught type error : Cannot read value 'name' of undefined
    primarykey
    data
    text
    <p>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.</p> <pre><code> $(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&lt;productJSON.length;i++){ var pagedisplay = ''; for(var j=0;j&lt;2;j++){ var generatedProductDisplay = ''; generatedProductDisplay = '&lt;div id="'+productJSON[a].id+'" class="productDiv"&gt;&lt;a class="productLink" href="#"&gt;&lt;center&gt;&lt;div class="productImage"&gt;&lt;img src="'+productJSON[a].image+'" width="100%" height="200px" alt="'+productJSON[a].name+'"&gt;&lt;/div&gt;&lt;div&gt;&lt;p class="productName"&gt;'+productJSON[a].name+'&lt;/p&gt;&lt;/div&gt;&lt;/center&gt;&lt;/a&gt;&lt;/div&gt;'; pagedisplay = pagedisplay+generatedProductDisplay; a++; } pagedisplay = pagedisplay+'&lt;br/&gt;'; $(".productDisplay").append(pagedisplay); } $(".productDiv").live("click",function(){ alert("Hello"); }); }); </code></pre> <p>This is the HTML code</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Welcome to Nitin Agro Industries, Chhatarpur&lt;/title&gt; &lt;link href="styles/main.css" type="text/css" rel="stylesheet" /&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="productsDisplay.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;center&gt; &lt;div class="page-wrap"&gt; &lt;div class="centerContent"&gt; &lt;h1&gt;Explore our Product Catalog&lt;/h1&gt; &lt;div class="centerText"&gt; &lt;center&gt; &lt;div class="hideShowDiv"&gt; skdddddddddddd &lt;/div&gt; &lt;div class="productDisplay"&gt;&lt;/div&gt; &lt;/center&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload