I have an ajax response which returns an array of two Json objects. The second object contains dynamic keys, which i'm using below to get the values. The problem is that i'm confused about how i can get it in ajax response. I know the starting name of the key and it ends with numbers from 1,2 or 3.. corresponding to the dynamic keys..Normally we get the value by giving data[1].checkservice but here the key is dynamic.
$.ajax({
type: 'POST',
url: "fetch",
dataType: 'json',
data: {clientidedit:clientidedit},
success: function(data) {
count = Object.keys(data[1]).length/6;
for(i=1;i<=count;i++){
abc ='checkservice'+i;
console.log("abc is :::"+abc)
console.log("value is "+data[1].abc);
}
});
By printing console.log("value is "+data[1].checkservice1) i'm getting exact value. But while printing console.log("value is "+data[1].abc) i'm getting undefined.