Konstantin Mokhov Konstantin Mokhov - 1 month ago 8x
Javascript Question

get variable from json response

I have a GET function and response in JSON.
This is function:

contentType: 'application/json',
dataType: 'json',
success: function(msg){
var result = JSON.stringify(msg);
error: error,
type: 'GET',
url: myurl

success response from 'result' is like this

But when I try to get the 'name' from response, I get an error!
This is the error:

for(var k in result){

displays the letters

I tried this:

$.each(result,function(index, value){
console.log(index, value);

but always get error.


Try removing the JSON.stringify(msg.response). After which, msg.response.values[0].name should givejohn