Using jquery I am trying to read values from a json file and populate in a dropdown.
For that I am doing the following
but undefined value is getting in dropdown.
What's wrong with my code?
json file
{
"VMs":[
{
"ID":"VM-WIN7-64",
"OS":"Windows 7",
"FLAVOUR":"VM-IE8-001-preq",
"ADAPTER":"Win 9"
}
],
"Paths":{
"VM-WIN7-64":"C:\\VirtualMachines\\Win7_X64_VM-001\\Win7_X64_VM-001.vmx"
}
}
code
function getOsNames() {
$.getJSON('/json/data.json', function(data)
{
var html = '';
$.each(data,function(val,i)
{
alert(val);
html += '<option value="' + val.OS + '">' + val.OS + '</option>';
});
$('#op').html(html);
});
}