我在Ajax调用oncomplete时向我的网站添加了一个JavaScript文件(使用appendChild)。之后,我试图调用该文件中包含的函数。像这样:检查JavaScript是否在Ajax调用中加载?
// 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()”。问题是,我怎么知道它何时被定义?
谢谢!
tes如果它不是未定义的可能? –
http://stackoverflow.com/questions/6725272/dynamic-cross-browser-script-loading – Prinzhorn
'typeof(myFunction)===“undefined”' – BrunoLM