我在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