This is the Json Data
{ "siteList": [ { "siteName": "Site1", "deviceList": [ { "deviceName": "S1device1", "count": "1" }, { "deviceName": "S1device2", "count": "2" } ] }, { "siteName": "Site2", "deviceList": [ { "deviceName": "S2device1", "count": "1" }, { "deviceName": "S2device2", "count": "2" } ] }, { "siteName": "Site3", "deviceList": [ { "deviceName": "S3device1", "count": "1" }, { "deviceName": "S3device2", "count": "2" } ] } ] }
This is The Code I tried
$(document).ready(function(){
$.ajax({
url:'user.json',
dataType: 'json',
success: function(json)
{
// get the `airport` array
var device= json.siteList.deviceList;
// loop through the array to populate your list
$.each(device, function(i, currentAirport) {
// add and option tag to your existing list
$('#yourlist').append(new Option( "<tr>"+"<td>"+currentAirport.deviceName+"</td>"+"</tr>" ));
});
}
});
});
The Output is attached below:
Please Help me Figure Out this code finding no clue about this
I want to get the siteName,deviceName and count
Any Help would be highly appreciated, Thank you in advance