0

I am sending some request on a server and it's reply me this:

{
    "count": 100,
    "entries": [
        {
            "id": 7563,
            "application": "my-app",
            "user": "admin",
            "time": "2012-10-10T11:32:09.324+07:00",
            "values": {
                "/my-app/name": "4d79f56b-1a20-4b25-bff6-b5f1d7253790"
            }
        },
        {
            "id": 7561,
            "application": "my-app",
            "user": "admin",
            "time": "2012-10-10T11:32:08.687+07:00",
            "values": {
                "/my-app/name": "4d79f56b-1a20-4b25-bff6-b5f1d7253790"
            }
        }
}

I tried, but nothing seems to working for me!

 var my_JSON_object = {};
 var xmlhttp = new XMLHttpRequest();

 my_JSON_object = JSON.parse(xmlhttp.responseText);

 xmlhttp.open("GET",url,true);
 xmlhttp.sand();

Everything is fine. but values return null.
Any help would be appreciated!

[my code]

1

3 Answers 3

3

correct your code:

 xmlhttp.open("GET",url,false);
 xmlhttp.send();

 //get response after sending request
 my_JSON_object = JSON.parse(xmlhttp.responseText);
Sign up to request clarification or add additional context in comments.

Comments

1
 alert(my_JSON_object.entries.id);

1 Comment

Available. but alert(my_JSON_object.entries[0].values) it's return null
0

Easiest way is just to use jQuery to do it:

$.getJSON(url, function(data) {
    alert(data.count);
    ...
});

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.