I do an ajax query and loop through the response. It returns two ids but I want to collect one by one. If in the future I have 5 ids I want to have the ids in different th. These ids are for dynamic th os passing the loop
$.ajax({
url: '',
type: 'GET',
data: '',
async: false,
success: function(response){
var nom = JSON.parse(response);
console.log(nom)
for (var x = 0; x<nom.length; x++){
ids=nom[x].id
console.log(ids)
}
The answer is id:1, id:2
It is like storing each generated id in the same variable but without repeating
You can use the function
Array.map()
to get all the propertiesid
of each element of the array that you have received: