I have one JSON file sample
{a:'spc432',
 b:'lll432'
}
I am trying to get JSON file from client side. and html also written at client side only.
After that I want to find out each ID from JSON file dynamically. How can we get Ids with knowing JSON file Ids..?
I tried below coding, but it is not working. Could you please check?
<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-1.5.js"></script>
  <script>
        $(document).ready(function(){
            alert("hi");
            $.get("json_text.txt", function(data) 
                    { alert("length = "+data.length); 
                                          for( i = 0; i< data.length; i++)
                                             alert("key name "+data[i].id);
                                         }
                  );
                    
        });
    </script>
</head>
<body>
</body>
</html>
                To get the key names you can do:
for(var key in data){ alert('key name: ' + key + ' value: ' + data[key]); }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With