为什么不能在ajax成功返回时访问渲染函数?也许我会疯了,但我以前做过。javascript undefined
它告诉我,this.render不是一个函数?
DataItem.prototype = {
display: function() {
$('body').append(this.name + ": " + this.getData(this.rootData, this.subData) + "<br />");
},
getData: function (rootData, subData) {
$.ajax({
type: "GET",
url: "json/data.js",
data: "",
dataType: "json",
success: function (json){
this.render(json);
}
});
},
render: function (json) {
var res = [];
for(var i=0, t; t=json.log.entries[i]; i++) {
var p = t.request.url;
if (p!=undefined) res.push(p);
}
return res.length;
}
};
以及您如何使用该功能? – 2009-11-08 12:35:11
@Alan - 你可以显示DataItem的完整代码吗? – 2009-11-08 12:43:22