Injecting javascript dynamically and using it
<p>I also create a javascript file dynamically that uses those variables:</p>

<pre><code>      function callbackF(data){
          console.log(data.script);

          document.getElementsByTagName('head')[0].innerHTML=data.script;

        var script = document.createElement("script");
    script.setAttribute("src", "http://widget.example.com/sprk.1.0.2.js");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("id", "grazit_script");
    document.getElementsByTagName('head')[0].appendChild(script);
        }
</code></pre>

<p>This is what i get in my head:</p>

<p>This is what is printed to the console log:</p>

<pre><code>&lt;script type='text/javascript'&gt;var dbnwid=16476; var dbnpid=23369; var dbnwebid=19720; var dbnlayout=21; var dbncolor='#000000'; var dbntitlefontsize='14'; var dbnbgcolortype=1; var dbnheader='You might enjoy reading:'; var dbnremindercolor=2; var dbn_protocol = (('https:' == document.location.protocol) ? 'https://' : 'http://'); &lt;/script&gt; 
</code></pre>

<p>and then the script:</p>

<pre><code>&lt;script src="http://widget.example.com/sprk.1.0.2.js" type="text/javascript" id="grazit_script"&gt;&lt;/script&gt;
</code></pre>

<p>The second script should get the variables that are in the second script..but it doesnt..then it complains about why it doesnt get those variables</p>

<blockquote>
  <p>UPDATE: 
  Both of those ways below didnt work for me:</p>
</blockquote>

<pre><code>  eval(data.script);
           var ss= new Function(data.script)();
</code></pre>
