爲什麼不能在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