1

In my application I want to hit an URL and I use to get a return data in JSON format as follows:

{
    "Status": {
        "itemlist": [{
            "image": "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316145577.jpg",
            "id": "1"
            Name: "xxx"
        }, {
            "image": "http://XXXXXXXXXXXXXXXXXX.com/images/original/1316145577.jpg",
            "id": "2"
            Name: "xxx"
        }]
    }
}

I want to do JSON parsing and display the return value in listview using JavaScript. Please help me. I have parsed using the following code:

function appReady() {
    alert("verified");
    var API = "http://XXXXXXXXXXXXXXXXXXXXXXXXX";
    check(API);
}

function check(API) {
    alert("entered");
    var http_request = new XMLHttpRequest();
    alert(http_request);
    http_request.open("GET", API, false);
    http_request.send(null);
    var my_JSON_object = http_request.responseText;
    alert(my_JSON_object);
    var data = JSON.parse(my_JSON_object);
    var Itemlist = [];
    for (var i = 0; i < Status.length; i++) {
        Itemlist[i] = data.Status.Itemlist[0].id;
        alert(id);
        Itemlist[i] = data.Status.Itemlist[0].Name;
        alert(Name);
        Itemlist[i] = data.Status.Itemlist[0].image;
        alert(image);
    }
    alert("id");
}
document.addEventListener("deviceready", appReady, false);

I want show progress spinner instead of alert thrown in my code. I also want to make a list view with return data. Please help me.

1 Answer 1

1

first there are some syntax error in given JSON string.

you can try this way

var itemList = json.Status.itemlist;
for(var i=0;i<itemList.length;i++)
{
    alert('Image:'+itemList[i].image
     +'\nID:'+itemList[i].id
        +'\nName:'+itemList[i].Name);
}

see the

DEMO

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

1 Comment

thak u very much.i need the images tobe displayed pls help me

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.