Hailwood
Hailwood

Reputation: 92601

Getting json response from variable?

If doing console.log(data) from inside a function that get passed the result of an AJAX request outputs

in the google chrome developer tools, I am wondering how I can get to the value of result? I think the entire response is being interpreted as a string? normally I would just use the dataType parameter, but I do not have control over this AJAX request.

Upvotes: 0

Views: 82

Answers (2)

Eugene Naydenov
Eugene Naydenov

Reputation: 7295

data.response property contains an object that is serialized to JSON, so you have to unserialize it in this way:

var response = JSON.parse(data.response),
    result = response.result;

Upvotes: 2

SLaks
SLaks

Reputation: 887499

You're trying to parse the JSON:

 var data = JSON.parse(obj.response);

Upvotes: 1

Related Questions