tags:

views:

29

answers:

1

Hi guys:

Assume the JSON returned is

{"2010143545":{"info":[1,"soccer"]},
 "2010143547":{"info":[0,"Basketball"]}
}

How do I use JQuery to render the array on ASP.NET page? More precisely, what kind of HTML template do I need to set to stuff the JSON with JQuey?

Thanks you.

A: 

HTML for a result div:

<div id="myDiv">Results here</div>

And the JS. I'll try to make it clear how to use it.

$.get("webservice.asmx?id=555", function(data){
    var str = "";
    for(var i = 0; i < data.length; i++){
        var number = data[i];           // When i=0, this is "2010143545"
        var infoName = data[i].info[1]; // When i=0, this is "soccer"

        // Example of rendering
        str += "<p>The number " +number+ " holds the name " +infoName+ "</p>";
    }
    $("#myDiv").html(str);
});
Simeon