只有在我不通过jQuery追加它时才执行的脚本?

mar*_*zzz 0 javascript jquery social-networking

这是我的代码:

<script src="http://widgets.twimg.com/j/2/widget.js"></script><script>new TWTR.Widget({version: 2,type: "profile",rpp: 4,interval: 30000,width: 650,height: 202,theme: {shell: {background: "#7ee1fc",color: "#2e2e2e"},tweets: {background: "#ffffff",color: "#949494",links: "#009ece"}},features: {scrollbar: true,loop: false,vlive: false,hashtags: true,timestamp: true,avatars: false,behavior: "all"}}).render().setUser("microsoft").start();</script>
Run Code Online (Sandbox Code Playgroud)

加载一个twitter插件(但事实上,这并不重要).那么,现在,如果我用"字符串"编写整个代码并通过jQuery追加它:

var myText='<script src="http://widgets.twimg.com/j/2/widget.js"><\/script><script>new TWTR.Widget({version: 2,type: "profile",rpp: 4,interval: 30000,width: 650,height: 202,theme: {shell: {background: "#7ee1fc",color: "#2e2e2e"},tweets: {background: "#ffffff",color: "#949494",links: "#009ece"}},features: {scrollbar: true,loop: false,vlive: false,hashtags: true,timestamp: true,avatars: false,behavior: "all"}}).render().setUser("microsoft").start();<\/script>'

$('#twitterContent').html(myText);
Run Code Online (Sandbox Code Playgroud)

似乎它无法加载它(我得到一个错误,TWTR没有定义).

那么为什么一个版本应该有效而另一个版本不适用?我该如何解决这个问题呢?

PS如果你想要测试代码,就是小提琴.

ade*_*neo 5

jQuery版本:

$.getScript("http://widgets.twimg.com/j/2/widget.js", function() {
new TWTR.Widget({id: 'twitterContent',version: 2,type: "profile",rpp: 4,interval: 30000,width: 650,height: 202,theme: {shell: {background: "#7ee1fc",color: "#2e2e2e"},tweets: {background: "#ffffff",color: "#949494",links: "#009ece"}},features: {scrollbar: true,loop: false,vlive: false,hashtags: true,timestamp: true,avatars: false,behavior: "all"}}).render().setUser("microsoft").start();
})?;
Run Code Online (Sandbox Code Playgroud)

小提琴