0

I use angularjs for read a particular json value :

$http({method: 'GET', url: urlVersion}).
success(function(data, status, headers, config) {
    console.log("success data " + status);
    $scope.ext = data.versions['chrome'];
}).
error(function(data, status, headers, config) {
    console.log("error data " + status);
});

json file is :

{
    "versions": {
        "android": "none",
        "chrome": "0.1"
    }
}

i have nothing in return and console give me no error... what's wrong ?

3
  • Shouldn't it be $scope.ext = data.versions.chrome; Commented Aug 4, 2014 at 21:28
  • @Acsisr: Both is valid with JS. @JoDiii: Does the console.log for the "success data " fire? Commented Aug 4, 2014 at 21:30
  • @ Acsisr : nothing in result, @ Charminbear : yes i have "success data 200" Commented Aug 4, 2014 at 21:32

2 Answers 2

1

Add responseType: 'json' to the http request and print the whole data object to console.

Sign up to request clarification or add additional context in comments.

1 Comment

Object {versions: Object} versions: Object android: "none" chrome: "0.1"
0

To Read the value of say for example 'chrome'

You have to read it as below

data[0].versions['chrome'];


To read the data of the json.You need to have the index of the elment.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.