here in this code i am trying to get the json value. I can get the key value, but I can not get the value of val.
How can i do this?
JQuery Code:
$.getJSON('data.json', function(data) { var items = []; $.each(data, function(key, val) { alert(key); alert(val); items.push('<option value="' + key + '">'+key+'</option>');
here is the json data
{ "trng-java": {"1":"5"}, "trng-jast": {"2":"5"}, "trng-caml": {"3":"4"}, "trng-linx": {"1":"5"} }
When I run this, I get the key value, but the val value appears as an Object.
source share