我正在尝试使用dojo工具包读取json对象,但dojo.forEach不起作用,我该如何阅读此对象?
这是我的代码:
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."
}
});
}