Embed <script> through jQuery?
<p>I'm trying to append a twitter script along with some HTML via a for each loop. The loop forks fine, until I add the <code>&lt;script&gt;</code> tags at the end. What I'm trying to do is have jQuery spit out my data and then put a twitter tweet button below the information. </p>

<p>I'm wondering if there's another way to get jQuery to append the script to my <code>#entries</code> div. </p>

<p>My code is below:</p>

<pre><code>$.each(data.Entries, function(entriesIndex, entriesObject) {

    if (entriesObject.Field21 == "Yes") {

        if (entriesObject.Field15 == "Yes") {

            $("&lt;li /&gt;", {
                html: '&lt;p&gt;&lt;a href="http://twitter.com/share"&gt;foo&lt;/a&gt;&lt;script type="text/javascript" src="http://platform.twitter.com/widgets.js"&gt;&lt;/script&gt;&lt;/p&gt;'


                // Add it to the page
            }).appendTo("#entries");

        } // end if entry = yes
    } // end if approved = yes

}); // end for each loop
</code></pre>

<p><em>update</em></p>

<p>Looks like it puts the script on the page but does not fire - not super familiar with how the twitter script works, but wondering if you guys could help! Thanks!</p>

<p>See an example page here: <a href="http://bostonwebsitemakeover.com/vote.html" rel="nofollow">http://bostonwebsitemakeover.com/vote.html</a></p>

<pre><code>    $.each(data.Entries, function(entriesIndex, entriesObject) {

        var p, tweet; // oh hey look, variables!

        if (entriesObject.Field21 == "Yes") {

            if (entriesObject.Field15 == "Yes") {

                     p = $("&lt;p /&gt;", {
                    html: "&lt;p&gt;" + '&lt;a href="' + entriesObject.Field19 + '" target="_blank"&gt;' + entriesObject.Field4  +  "&lt;/p&gt;" + '&lt;img src="http://images.websnapr.com/?url=' + entriesObject.Field19 + '" /&gt;' + "&lt;/a&gt;"
                    });

                     tweet = $('&lt;script&gt;').attr({
                        type: 'text/javascript',
                        src: 'http://platform.twitter.com/widgets.js'

                    });

            } // end if entry = yes

        } // end if approved = yes


        $('&lt;li class="entry"&gt;').append(p).append(tweet).appendTo('#entries');

}); // end for each loop
</code></pre>
