+1 vote
by
Hello!

I have a beef, explain RV-hundred anyone why the result is undefined:

Have the response in Json format and object with other objects, trying to access one of them:

var next = responce.n;
console.log($obj[next]);

- get undefined

If you attempt to do so:

var next = 'a1';
console.log($obj[next]);

- get what you need!

check responce.next:

console.log(responce.n);

all as you need is kept here just a1

Live example

What is my mistake?
by
Ilya Shatokhin behold, the most simple example: https://jsfiddle.net/83t6647x/13/
by
Arthur Selivanov anyway without an example it is not clear. Show me in pastebin or here a non-working piece of code that can be repeated.
by
Ilya Shatokhin : Yes there is the usual returns in the ajax success: function (responce) { ... }, the contents of the response object - n: "A1" , to work with him without problems, but when I try to substitute when referring to the object element, you get undefined (
by
Need an example of code line by line and even telepaths will not help.

1 Answer

0 votes
by
 
Best answer
You have one example of "a" in Cyrillic and the other Latin. Looks the same, but in fact not the same.
...