1
我想在使用純JavaScript加載腳本後執行回調。我能夠正確加載腳本,但我的回調沒有觸發。我聽說使用JSONP我可以做這種類型的東西,但是,我不能完全使它工作。這裏是我的代碼:JSONP腳本回調不起作用
function foo(){
alert('got the data');
}
var el = document.createElement("script");
el.setAttribute("src", "//ajax.googleapis.com/ajax/libs/webfont/1.5.0/webfont.js?callback=foo");
document.body.appendChild(el);