title: How To Loop Through Set Of Value Pairs JSON Object
body: <p>im trying to loop through  a JSON object via Jquery. For some reason its not looping right.. It seems to be looping all the way to the end, But I would like to get each individually property in my object. Im using a For(var in) loop which loops through my object correctly but its a bit off.. MyAny help would be glady appreciated.. thanks so much!!! I can provide a quick link to my website that has mock up of the code if needed..
  Ive also added more code and html via elements that using ..Hint*** Theres more if - conditional statements that checks for sounds_like,sounds_price...    The first JSON Object works with no problem, its the second JSON object that im using with the pop over thats causing me trouble</p>
  
  <pre><code>    &lt;div class="overlay-bg"&gt;
           &lt;div id= "overlay" class="overlay-content"&gt;
               &lt;p&gt;This is a popup!&lt;/p&gt;
            &lt;button class="close-btn"&gt;Close&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
          $.getJSON("php/music_data.php",function(data){
               $.each(data,function(key,obj){
  
                   for(var prop in obj){
                       // console.log("Property: " + prop + " key:" + obj[prop]);
                       if(prop === "sounds_like"){
  
                           results_div =  document.getElementById("results");
                           music_div_container = document.createElement("div");
                           music_div_container.id  = "music_data_container";
                           music_div_container.innerHTML = "&lt;div id=\"sounds_like\"&gt;" + "Sounds Like: "  + obj["sounds_like"] +"&lt;/div&gt;";
                           results_div.appendChild(music_div_container);
  
                           var pop_up = document.createElement("a");
                           pop_up.href = "#";
                           pop_up.className = "show-popup";
                           pop_up.innerHTML = "Click";
                           music_div_container.appendChild(pop_up);
  
                           default_photo = document.createElement('div');
  
  
                       }
  
                       if(prop === "sound_desc"){
  
                           var sound_desc = document.createElement("div");
                           sound_desc.innerHTML  = "&lt;div id=\"sounds_desc\"&gt;" +        obj["sound_desc"] +"&lt;/div&gt;";
                           music_div_container.appendChild(sound_desc);
  
                       }
  
  
       $.getJSON("php/music_data.php",function(data){
     $.each(data,function(idx,obj){
  
      $.each(obj,function(key,value){
  
          $(".show-popup").click(function(event){
  
              event.preventDefault();     
              $(".overlay-bg").show();
  
                if(key === "sounds_like"){
                            /***Should be Beyonce,Drake,Nicki Minaj***/
                            /*****But my console is showing Nicki Minaj*******/
                    $(".overlay-content").html(value);
                }
              if(value === "sounds_desc"){
                             /***Should be Smooth, Wu tang Forever, Barbie***/
                            /*****But my console is showing Barbie*******/
                  $(".overlay-content").html(value);
               }
  
  
              $('.close-btn').click(function(){
                  $('.overlay-bg').hide(); /*** hide the overlay ***/
              });
  
              $('.overlay-bg').click(function(){
                  $('.overlay-bg').hide(); 
              });
  
              $('.overlay-bg').click(function(){
                  return false;
              })
          });
      });
  
     })
   });
  </code></pre>
  
  <p>JSON Object Below</p>
  
  <pre><code>[{"id":"39","sounds_like":"Beyonce","sound_name":"Dance 4 u.mp3","sound_desc":"Smooth","sound_genre":"R&amp;B","sound_price":"N/A","photo_path":"\/admin_data\/uploaded_artist_photos\/","photo_name":"beyonce.jpg"},
   {"id":"40","sounds_like":"Drake","sound_name":"Bottom.mp3","sound_desc":"Wu Tang Forever","sound_genre":"Rap","sound_price":"N/A","photo_path":"\/admin_data\/uploaded_artist_photos\/","photo_name":"drake.jpg"},
   {"id":"41","sounds_like":"Nicki Minaj","sound_name":"RomanReloaded.mp3","sound_desc":"Barbie","sound_genre":"Rap","sound_price":"N/A","photo_path":"\/admin_data\/uploaded_artist_photos\/","photo_name":"nickiminaj.jpg"}
  ]
  </code></pre>