using jquery read values from a json file -
Using jquery, I am trying to read values from json file and populate in dropdown.
I do the following but what is wrong in my code in undefined
price dropdown? Json File
{"VMs": [{"ID": "VM-Wine 7-64", "OS": "Windows 7", "Flavor": "VM-IE8 -001-subjective "," adapter ":" win 9 "}]," path ": {" VM-win 7-64 ":" C: \\ Virtual Mics \\ 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 + = '& lt; option value =' '+ val.OS +' "> '+ val.OS + '& Lt; / option & gt;';}); $ ('# op'). Html (html);}); }
Looping you through data.VMs
This OS property is going to be
function getOsNames () {$ .getJSON ('/ json / data.json', function) {var html = ''; $ .each VVM, function (i, wal) {html + = '& lt; option value =' '+ val.OS +' "> gt; '+ val.OS +' gt; ';}) ; $ ('#op') Html (html);}); }
Demo:
Comments
Post a Comment