title: Get value from JSON string using jQuery
body: <p>I'm trying to parse JSON string with few arrays and some key:value pairs. I'm now able to get values from one array but I want to get values from the other array too. The arrays have same keys but I can't find out how to get data from the second array.</p>
  
  <p>My jQuery script looks like this</p>
  
  <pre><code>$("a").click(function () {
      var page = $(this).text();
      console.log(page);
      $.post("/services/gallery/getimage", {"path[]":[&lt;%=path %&gt;], "page": page}, function(data){
          var length = data.previews.length;
          console.log(length);
          var html = "";
          for(var i = 0; i &lt; length; i++){
              $.each(data.previews[i], function (index, value) {
                  html+= "&lt;a href=\""+value+"\"&gt;&lt;img src=\""+value+"\" alt=\""+index+"\" /&gt;&lt;/a&gt;";
                  console.log("index: "+index);
                  console.log("value: "+value);
                  console.log(data.heights[i].index);
              });
          }
  
          $("#gallery").html(html);
      });
  });
  </code></pre>
  
  <p>I've also tried some modifications of this <code>console.log(data.heights[i].index);</code> but still no usable result.</p>
  
  <p>The console output is</p>
  
  <pre><code>1
  15
  
  index: index1
  value: /some/path
  undefined
  
  index: index2
  value: /some/paht
  undefined 
  </code></pre>
  
  <p>and the JSON string looks like this</p>
  
  <pre><code>{
      "previews": [
          {
              "index1": "/some/path"
          },
          {
              "index2": "/some/path"
          }
      ],
      "heights": [
          {
              "index1": "67"
          },
          {
              "index2": "103"
          }
      ]
  }
  </code></pre>
  
  <p>I'll have more arrays with same indexes so it'll be great if it'll be possible to parse it in one for. Thanks for any help</p>
  
  <p><strong>EDIT:</strong> Names of attributes are dynamic not static. It can be whatever, not just index1, index2, ... </p>