am trying to read a json object with dojo toolkit, but the dojo.forEach do not work so , how can i read this 开发者_如何学运维object?
this is my code:
function loadThemes() {
themes= " ";
// The "xhrGet" method executing an HTTP GET
dojo.xhrGet({
url: "theme/consult",
handleAs: "json",
headers: { "Content-Type": "application/json", "Accept" : "application/json"},
load: function(jsonData) {
var content = "";
dojo.forEach(jsonData.theme,function(themes) {
content+= "<h2>" + themes.name + "</h2>";
content+= "<p>" + themes.description + "</p>";
});
dojo.byId("themes2").innerHTML = content;
},
error: function() {
dojo.byId("themes2").innerHTML = "News is not available at this time."
}
});
}
精彩评论