【发布时间】:2011-07-02 20:54:16
【问题描述】:
我正在创建一个名为 ImageRotatorManager 的 JavaScript 类来管理动态加载的幻灯片。通过 xml 加载图像时,我定义了以下函数:
/* Loads configuration settings for the image rotator */
ImageRotatorManager.prototype.loadXML = function (callback) {
jQuery.get("assets/image-rotator.xml", {}, function (xml) {
parseXML(xml, callback); //the callback function
});
};
/* Loads configuration settings for the image rotator */
function parseXML(xml, callback) {
//find every image and add the image to the '#slideshow' div
};
函数parseXML(xml, callback)调用成功。
但是,如果我将 parseXML() 定义为 ImageRotatorManager.prototype.parseXML = function (xml, callback) 并使用 ImageRotatorManager.parseXML(xml, callback); 调用此函数,则会收到以下错误:
ImageRotatorManager.parseXML 不是函数
为什么会出现此错误?我使用此签名进行其他函数调用,它们工作正常。
【问题讨论】:
标签: javascript function prototype-programming