Recently Updated:
Complete values of respons
:
"{"versions":[
{
"name":"Windows 8.1 with Update 3 (build 9600)",
"version_id":"11"
},
{
"name":"Windows 7 SP1 (build 7601)",
"version_id":"9"
},
{
"name":"Windows 10, Version 1803 - Redstone 4 [Apr 2018] (build 17134.1)",
"version_id":"97"
},
{
"name":"Windows 10, Version 1709 - Redstone 3 [Sep 2017] (build 16299.15)",
"version_id":"92"
},
{
"name":"Windows 10, Version 1703 - Redstone 2 [March 2017] (build 15063.0)",
"version_id":"41"
},
{
"name":"Windows 10, Version 1607 - Redstone 1 [Jul 2016] (build 14393.0)",
"version_id":"16"
},
{
"name":"Windows 10, Version 1511 - Threshold 2 [Nov 2015] (build 10586.0)",
"version_id":"13"
},
{
"name":"Windows 10, Version 1511 - Threshold 2 [Feb 2016] (build 10586.104)",
"version_id":"14"
},
{
"name":"Windows 10, Version 1511 - Threshold 2 [Apr 2016] (build 10586.164)",
"version_id":"15"
},
{
"name":"Windows 10, Version 1507 - Threshold 1 [Jul 2015] (build 10240.16384)",
"version_id":"12"
}
]
}"
An array in the following format has been provided:
{
"versions":[
{
"name":"Windows 8.1 with Update 3 (build 9600)",
"version_id":"11"
},
{
"name":"Windows 7 SP1 (build 7601)",
"version_id":"9"
},
{
"name":"Windows 10, Version 1803 - Redstone 4 [Apr 2018] (build 17134.1)",
"version_id":"97"
}
]
}
The goal is to extract name
and version_id
for adding them to a select dropdown list.
The desired outcome should look like this:
success: function(response){
var options = '';
$(response.versions).each(function() {
options += '<option value="' + $(this).attr('version_id') + '">' + $(this).attr('name') + '</option>';
});
https://i.sstatic.net/kJFOM.png
However, there seems to be an issue in retrieving version_id
and name
. Is there any alternative method to achieve this?