title: How to display images using Javascript and JSON
body: <p>I have to display images to the browser and I want to get the image from a JSON response and display it to the browser using Javascript. This is what the JSON response looks like:</p>
  
  <pre><code>[{
      "0":"101",
      "member_id":"101",
      "1":"3k.png",
      "image_nm":"3k.png",
      "2":"\/images\/phones\/",
      "image_path":"\/images\/"
  },{
      "0":"102",
      "member_id":"102",
      "1":"mirchi.png",
      "image_nm":"mirchi.png",
      "2":"images\/phones\/",
      "image_path":"images\/phones\/"
  },{
      "0":"103",
      "member_id":"103",
      "1":"masti.png",
      "image_nm":"masti.png",
      "2":"images\/phones\/",
      "image_path":"images\/phones\/"
  }]
  </code></pre>
  
  <p>How do I do this (I am a beginner)? </p>
  
  <p>here is the code what i wrote...</p>
  
  <pre><code>       var jsonString =   '[{"0":"101","member_id":"101","1":"3k.png","image_nm":"3k.png","2":"\/images\/phones\/","image_path":"\/images\/phones\/"},{"0":"102","member_id":"102","1":"mirchi.png","image_nm":"mirchi.png","2":"images\/phones\/","image_path":"images\/phones\/"},{"0":"103","member_id":"103","1":"masti.png","image_nm":"masti.png","2":"images\/phones\/","image_path":"images\/phones\/"}]';
         var obj = JSON.parse(jsonString);
  
         for(var i = 0, len = obj.length; i &lt; len; i++){
         var img = new Image();
         img.setAttribute("src",obj[i][2] + obj[i][1]);
         document.body.appendChild(img);
           }
  </code></pre>