0

In my Ajax request the response data is an object like this:

enter image description here

how is possible to access value.

note: idVariable is a variable.

data.test1.idVariable.test2.value

Above code result is: undefined.

armani
  • 303
  • 7
  • 18

1 Answers1

1

When you are using a variable to name a key in a javascript object you are supposed to use bracket notation. E.g:

var idVariable = 8;
var value = data.test1[idVariable].test2.value;

Otherwise, you are accessing a key names idVariable, instead of 8

Damien Fayol
  • 958
  • 7
  • 17