2013-04-25 75 views
0

我想在dom中获取此文件,而不使用愚蠢的script标记。但是它超时了。通过异步插件加载addthis

require(["async!http://s7.addthis.com/js/300/addthis_widget.js"], function(addthis){ 

}); 

这里的控制台错误:

Uncaught Error: Load timeout for modules: async!http://s7.addthis.com/js/300/addthis_widget.js_unnormalized2,async!http://s7.addthis.com/js/300/addthis_widget.js 
http://requirejs.org/docs/errors.html#timeout 
+0

所以我试图击中两个异步尝试抓取的url,addthis_widget.js很好,但addthis_widget.js_unnormalized2找不到。你知道为什么异步正在寻找这个吗? – 2013-04-29 15:38:25

+0

我不知道那里发生了什么 – ThomasReggi 2013-04-29 17:48:03

回答

0

我不熟悉requirejs(!刚开始寻找到它今晚),但你可以这样来做:

var jsAddThis = document.createElement('script'), 
    head  = document.getElementsByTagName('head')[0]; 

jsAddThis.async = true; 
jsAddThis.type = 'text/javascript'; 
jsAddThis.src = 'http://s7.addthis.com/js/300/addthis_widget.js'; 

head.appendChild(jsAddThis);