我在 Ajax 调用 oncomplete 中将 JavaScript 文件添加到我的站点(使用 appendChild)。之后,我尝试调用该文件中包含的函数。像这样:
// append the JS to the head
document.getElementsByTagName('head')[0].appendChild(element);
// call a function that is contained in the js file
myFunction();
对 myFunction 的调用显示“myFunction() 未定义”。问题是,我怎么知道它何时被定义?
谢谢!